package client;

import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.inventory.MapleWeaponType;
import client.skills.Skill;
import client.skills.SkillEntry;
import client.skills.SkillFactory;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import constants.ItemConstants;
import constants.JobConstants;
import constants.SkillConstants;
import constants.skills.*;
import handling.opcode.EffectOpcode;
import handling.opcode.SendPacketOpcode;
import handling.world.party.MaplePartyCharacter;
import server.MapleStatEffect;
import server.MapleStatEffectFactory;
import server.MapleStatInfo;
import server.Timer;
import server.life.MapleMonster;
import server.maps.*;
import server.quest.MapleQuest;
import server.skill.MapleForceAtom;
import server.skill.MapleForceAtomFactory;
import tools.*;
import tools.data.output.MaplePacketLittleEndianWriter;
import tools.packet.*;

import java.awt.*;
import java.util.*;
import java.util.List;

/**
 * 免责声明：本模拟器源代码下载自ragezone.com，仅用于技术研究学习，无任何商业行为。
 */
public class PlayerSkillHandler {

    /*
     * 修复技能
     */
    public static void baseSkills(MapleCharacter player) {
        player.checkZeroItem();
        player.checkInnerSkill();
//        checkZeroWeapon();
        checkBeastTamerSkill(player);
        player.checkHyperAP();
        Map<Integer, SkillEntry> list = new HashMap<>();
        if (JobConstants.getJobGrade(player.getJob()) >= 3) { //third getJob().
            List<Integer> baseSkills = SkillFactory.getSkillsByJob(player.getJob());
            if (baseSkills != null) {
                for (int i : baseSkills) {
                    Skill skil = SkillFactory.getSkill(i);
                    //System.err.println("夜光技能: " + !skil.isInvisible() + " - " + skil.getMasterLevel() + " - " + skil.getId() + " - " + skil.getName());
                    if (skil != null && !skil.isInvisible() && SkillConstants.isFourthJob(skil.getId()) && player.getSkillLevel(skil) <= 0 && player.getMasterLevel(skil) <= 0 && skil.getMasterLevel() > 0) {
                        list.put(i, new SkillEntry((byte) 0, (byte) (JobConstants.is超能力者(player.getJob()) ? skil.getMaxLevel() : skil.getMasterLevel()), SkillFactory.getDefaultSExpiry(skil))); //usually 10 master
                    } else if (skil != null && skil.getName() != null && skil.getName().contains("冒险岛勇士") && player.getSkillLevel(skil) <= 0 && player.getMasterLevel(skil) <= 0) {
                        list.put(i, new SkillEntry((byte) 0, (byte) 10, SkillFactory.getDefaultSExpiry(skil)));
                    } else if (skil != null && skil.getName() != null && (skil.getName().contains("希纳斯的骑士") || skil.getName().contains("希纳斯骑士")) && player.getSkillLevel(skil) <= 0 && player.getMasterLevel(skil) <= 0) {
                        list.put(i, new SkillEntry((byte) 0, (byte) 30, SkillFactory.getDefaultSExpiry(skil)));
                    }
                }
            }
        }
        Skill skil;
        if (player.getJob() >= 3300 && player.getJob() <= 3312) {
            int[] ss = {预备兵.捕获, 预备兵.猎人的召唤, 豹弩游侠.美洲豹骑士, 豹弩游侠.召唤美洲豹_灰, 豹弩游侠.利爪狂风, 豹弩游侠.激怒, 豹弩游侠.美洲豹管理};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is机械师(player.getJob())) {
            int[] ss = {预备兵.机械冲撞, 预备兵.隐藏碎片};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is火炮手(player.getJob()) && player.getLevel() >= 10) {
            skil = SkillFactory.getSkill(110);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(110, new SkillEntry((byte) 1, (byte) 1, -1));
            }
        } else if (JobConstants.is骑士团(player.getJob())) {
            int[] ss = {初心者.元素斩击, 初心者.回归, 初心者.元素和声_力量, 初心者.希纳斯护佑_战士, 初心者.元素跃动, 初心者.元素专家, 初心者.元素跃动_闪跃};
            if (JobConstants.is炎术士(player.getJob())) {
                ss[2] = 初心者.元素和声_智力;
                ss[3] = 初心者.希纳斯护佑_魔法师;
            } else if (JobConstants.is风灵使者(player.getJob())) {
                ss[2] = 初心者.元素和声_敏捷;
                ss[3] = 初心者.希纳斯护佑_弓箭手;
            } else if (JobConstants.is夜行者(player.getJob())) {
                ss[2] = 初心者.元素和声_运气;
                ss[3] = 初心者.希纳斯护佑_飞侠;
            } else if (JobConstants.is奇袭者(player.getJob())) {
                ss[3] = 初心者.希纳斯护佑_海盗;
            }
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
            if (JobConstants.is夜行者(player.getJob())) {
                int[] ss2 = {夜行者.影跃, 夜行者.快速闪避};
                for (int i : ss2) {
                    skil = SkillFactory.getSkill(i);
                    if (skil != null && player.getSkillLevel(skil) <= 0) {
                        list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                    }
                }
            }
        } else if (JobConstants.is恶魔猎手(player.getJob()) && player.getLevel() >= 10 && player.getJob() != 3001) {
            int[] ss = {恶魔猎手.恶魔跳跃, 恶魔猎手.死亡诅咒, 恶魔猎手.恶魔之翼1, 恶魔猎手.恶魔之血, 恶魔猎手.恶魔跳跃1, 恶魔猎手.恶魔跳跃2, 恶魔猎手.恶魔跳跃3};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is恶魔复仇者(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {恶魔复仇者.恶魔之翼, 恶魔复仇者.恶魔跳跃, 恶魔复仇者.恶魔之血, 恶魔复仇者.野性狂怒, 恶魔复仇者.血之契约, 恶魔复仇者.超越, 恶魔复仇者.高效吸收};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is尖兵(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {尖兵.急速支援, 尖兵.混合逻辑, 尖兵.多线程Ⅰ, 尖兵.机械战车冲刺, 尖兵.多模式链接, 尖兵.自由飞行, 尖兵.伪装};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is双弩精灵(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {双弩.精灵的祝福, 双弩.优雅移动, 双弩.王者资格, 双弩.精灵恢复, 20021160, 20021161};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is龙的传人(player.getJob()) && player.getLevel() >= 10) {
            skil = SkillFactory.getSkill(龙的传人.身轻如燕);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(龙的传人.身轻如燕, new SkillEntry((byte) 1, (byte) 1, -1));
            }
            skil = SkillFactory.getSkill(龙的传人.宝盒的庇佑);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(龙的传人.宝盒的庇佑, new SkillEntry((byte) 1, (byte) 1, -1));
            }
        } else if (JobConstants.is隐月(player.getJob())) {
            int[] ss = {隐月.精灵凝聚第1招, 隐月.缩地};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
            skil = SkillFactory.getSkill(隐月.九死一生);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(隐月.九死一生, new SkillEntry(1, (byte) 2, -1));
            }
            skil = SkillFactory.getSkill(隐月.冲击拳);
            if (player.getLevel() >= 10 && skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(隐月.冲击拳, new SkillEntry(0, (byte) 25, -1));
            }
            skil = SkillFactory.getSkill(隐月.闪拳);
            if (player.getLevel() >= 20 && skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(隐月.闪拳, new SkillEntry(0, (byte) 25, -1));
            }
            skil = SkillFactory.getSkill(隐月.九死一生);
            if (player.getLevel() >= 30 && skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(隐月.九死一生, new SkillEntry(2, (byte) 2, -1));
            }
        } else if (JobConstants.is幻影(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {幻影.幻影回归, 幻影.致命本能, 幻影.幻影屏障, 幻影.灵敏身手, 幻影.印技之瞳, 幻影.印技树, 20031160, 20031161, 幻影.审判_ONOFF};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
            if (player.getJob() == 2412) {
                skil = SkillFactory.getSkill(幻影.卡牌审判_高级);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(幻影.卡牌审判_高级, new SkillEntry((byte) 1, (byte) 1, -1));
                }
                skil = SkillFactory.getSkill(幻影.卡牌审判);
                if (skil != null && player.getSkillLevel(skil) > 0) {
                    list.put(幻影.卡牌审判, new SkillEntry((byte) 0, (byte) 0, -1));
                }
            } else {
                skil = SkillFactory.getSkill(幻影.卡牌审判);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(幻影.卡牌审判, new SkillEntry((byte) 1, (byte) 1, -1));
                }
                skil = SkillFactory.getSkill(幻影.卡牌审判_高级);
                if (skil != null && player.getSkillLevel(skil) > 0) {
                    list.put(幻影.卡牌审判_高级, new SkillEntry((byte) 0, (byte) 0, -1));
                }
            }
        } else if (JobConstants.is夜光(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {夜光.太阳火焰, 夜光.月蚀, 夜光.穿透, 夜光.平衡_光明, 夜光.光明黑暗模式转换, 夜光.光之力量, 夜光.光之传送};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
            int[] fixskills = {夜光.耀眼光球, 夜光.黑暗降临, 夜光.光明黑暗魔法强化};
            for (int f : fixskills) {
                skil = SkillFactory.getSkill(f);
                if (skil != null && player.getSkillLevel(skil) <= 0 && player.getMasterLevel(skil) <= 0 && skil.getMasterLevel() > 0) {
                    list.put(f, new SkillEntry((byte) 1, (byte) skil.getMasterLevel(), SkillFactory.getDefaultSExpiry(skil)));
                }
            }
        } else if (player.getJob() >= 432 && player.getJob() <= 434) {
            int[] fixskills = {双刀.双刀风暴, 双刀.暗影飞跃斩, 双刀.影子闪避, 双刀.幽灵一击, 双刀.终极斩};
            for (int i : fixskills) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && !skil.isInvisible() && SkillConstants.isFourthJob(skil.getId()) && skil.getMasterLevel() > 0) {
                    if (player.getSkillLevel(skil) <= 0 && player.getMasterLevel(skil) <= 0) {
                        list.put(i, new SkillEntry((byte) 0, (byte) skil.getMaxLevel(), SkillFactory.getDefaultSExpiry(skil)));
                    } else if (player.getMasterLevel(skil) <= skil.getMaxLevel()) {
                        list.put(i, new SkillEntry((byte) player.getSkillLevel(skil), (byte) skil.getMaxLevel(), SkillFactory.getDefaultSExpiry(skil)));
                    }
                }
            }
        } else if (JobConstants.is米哈尔(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {米哈尔.光之守护, 米哈尔.皇家守护};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is狂龙战士(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {狂龙战士.防御模式, 狂龙战士.攻击模式, 狂龙战士.垂直连接, 狂龙战士.变身, 狂龙战士.钢铁之墙};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is爆莉萌天使(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {爆莉萌天使.释世书, 爆莉萌天使.魔法裂隙, 爆莉萌天使.灵魂契约, 爆莉萌天使.协调, 爆莉萌天使.装扮};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                }
            }
        } else if (player.getJob() == 10112 && player.getLevel() >= 100) {
            List<Integer> baseSkills = SkillFactory.getSkillsByJob(10100);
            baseSkills.addAll(SkillFactory.getSkillsByJob(10110));
            baseSkills.addAll(SkillFactory.getSkillsByJob(10111));
            baseSkills.addAll(SkillFactory.getSkillsByJob(10112));
            for (int i : baseSkills) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && !skil.isInvisible() && SkillConstants.isFourthJob(skil.getId()) && player.getSkillLevel(skil) <= 0 && player.getMasterLevel(skil) <= 0 && skil.getMasterLevel() > 0) {
                    list.put(i, new SkillEntry((byte) 0, (byte) skil.getMaxLevel(), SkillFactory.getDefaultSExpiry(skil))); //usually 10 master
                }
            }
            int[] skillIds = {神之子.重归神殿, 神之子.双重打击, 神之子.圣洁之力, 神之子.神圣迅捷, 神之子.暴风一跃, 神之子.暴风步, 神之子.伦娜之庇护, 神之子.决意时刻, 神之子.提速时刻, 神之子.时光扭曲, 神之子.时间制控, 神之子.时光逆流, 神之子.影子雨印, 神之子.强化时间}; //100001262 重归神殿
            for (int i : skillIds) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && skil.canBeLearnedBy(player.getJob()) && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) skil.getMaxLevel(), (byte) skil.getMaxLevel(), -1));
                }
            }
        } else if (JobConstants.is剑豪(player.getJob())) {
            int[] ss = {剑豪.疾风传授, 剑豪.拔刀姿势, 剑豪.疾风五月雨刃, 剑豪.天赋之才, 剑豪.防御是最好的攻击};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) skil.getMaxLevel(), (byte) 1, -1));
                }
            }
        } else if (JobConstants.is阴阳师(player.getJob())) {
            int[] ss = {阴阳师.五行的加持, 阴阳师.无限之灵力, 阴阳师.小白, 阴阳师.紫扇传授};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) skil.getMaxLevel(), (byte) 1, -1));
                }
            }
        } else if (JobConstants.is超能力者(player.getJob())) {
            int[] ss = {超能力者.心魂突袭, 超能力者.回归, 超能力者.判断, 超能力者.心魂本能};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry((byte) skil.getMaxLevel(), (byte) 1, -1));
                }
            }
        } else if (JobConstants.is爆破手(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {预备兵.秘密广场紧急集结, 爆破手.转管炮, 爆破手.装填弹药};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (player.getJob() >= i / 10000 && skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry(1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is魔链影士(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {魔链影士.强力侮辱, 魔链影士.返回商团, 魔链影士.讲价};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (player.getJob() >= i / 10000 && skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry(1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is圣晶使徒(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {圣晶使徒.返回避难所, 圣晶使徒.持续战役};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (player.getJob() >= i / 10000 && skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry(1, (byte) 1, -1));
                }
            }
        } else if (JobConstants.is影魂异人(player.getJob()) && player.getLevel() >= 10) {
            int[] ss = {影魂异人.魔力线路, 影魂异人.无我之境};
            for (int i : ss) {
                skil = SkillFactory.getSkill(i);
                if (player.getJob() >= i / 10000 && skil != null && player.getSkillLevel(skil) <= 0) {
                    list.put(i, new SkillEntry(1, (byte) 1, -1));
                }
            }
        }
        List<Integer> fixSkills = SkillFactory.getSkillsByJob(player.getJob());
        if (fixSkills != null) {
            for (int i : fixSkills) {
                Skill sk = SkillFactory.getSkill(i);
                if (sk != null && sk.getFixLevel() > 0) {
                    if (sk.canBeLearnedBy(player.getJob()) && player.getSkillLevel(sk) <= 0) {
                        list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
                    }
                }
            }
        }
        if (!list.isEmpty()) {
            player.changeSkillsLevel(list);
        }
    }

    public static void handleAfterSkill(MapleCharacter player, MapleMonster monster, MapleStatEffect effect, long totalDamage) {
        long currTime = System.currentTimeMillis();
        int skillid = effect == null ? 0 : effect.getSourceid();
        switch (player.getJob()) {
            case 120:
            case 121:
            case 122: {
                Skill skill = SkillFactory.getSkill(1201012);
                MapleStatEffect skillEffect = player.getSkillEffect(1201012);
                if (skillEffect != null && player.isBuffFrom(MapleBuffStat.属性攻击, skill)) {
                    MonsterStatusEffect o2 = new MonsterStatusEffect(MonsterStatus.Freeze, 1, skill.getId(), null, false);
                    monster.applyStatus(player, o2, false, (long) (skillEffect.getY() * 2000), true, skillEffect);
                }
                break;
            }
            case 210:
            case 211:
            case 212:
            case 220:
            case 221:
            case 222:
            case 230:
            case 231:
            case 232: {
                MapleStatEffect skillEffect = player.getSkillEffect(火毒.燎原之火_MIST);
                if (skillEffect != null && player.getBuffedIntValue(MapleBuffStat.燎原之火) > 0 && skillEffect.makeChanceResult(player) && SkillConstants.isFireSkill(skillid)) {
                    monster.getMap().spawnMist(new MapleMist(MapleStatEffectFactory.calculateBoundingBox(skillEffect, monster.getTruePosition(), player.isFacingLeft()), player, skillEffect, monster.getPosition()), skillEffect.getDuration(), false);
                }
                if (player.getJob() == 212 || player.getJob() == 222 || player.getJob() == 232) {
                    int n4 = player.getJob() == 212 ? 火毒.神秘瞄准术 : (player.getJob() == 222 ? 冰雷.神秘瞄准术 : 主教.神秘瞄准术);
                    if (skillid == 冰雷.寒冰步 || skillid == 火毒.火焰灵气) {
                        return;
                    }
                    skillEffect = player.getSkillEffect(n4);
                    if (skillEffect != null) {
                        if (skillEffect.makeChanceResult()) {
                            skillEffect.applyTo(player);
                        }
                    }
                }
                MapleStatEffect statEffect = player.getSkillEffect(冰雷.寒冰之缘);
                if (skillid == 冰雷.冰封时代 && statEffect != null) {
                    PlayerSkillHandler.spawnMist(statEffect, player, monster.getPosition());
//                    monster.getMap().spawnMist(new MapleMist(MapleStatEffectFactory.calculateBoundingBox(skillEffect, monster.getTruePosition(), player.isFacingLeft()), player, skillEffect, monster.getPosition()), skillEffect.getDuration(), false);
                }
                break;
            }
            case 310:
            case 311:
            case 312: {
                MapleBuffStatValueHolder mbsvh = player.getBuffStatValueHolder(MapleBuffStat.三彩箭矢);
                if (mbsvh != null && monster != null && skillid != 95001000 && skillid != 神射手.三彩箭矢 && skillid != 神射手.进阶箭筒_魔法 && skillid % 10000 >= 1000) {
                    int value = mbsvh.getValue();
                    int mode = value / 10000;
                    int max = value / 100 % 100;
                    int curr = value % 100;
                    boolean passive = false;
                    MapleStatEffect skillEffect = player.getSkillEffect(神射手.进阶箭筒);
                    boolean n3 = player.getBuffedValue(MapleBuffStat.进阶箭筒) != null;
                    if (totalDamage > 0) {
                        switch (mbsvh.getZ()) {
                            case 1: {
                                if (Randomizer.nextInt(100) < (skillEffect != null ? skillEffect.getW() : 50)) {
                                    int n9;
                                    passive = (n9 = mode - (n3 ? 0 : 1)) <= 0;
                                    mode = passive ? (skillEffect != null ? skillEffect.getY() : 10) : n9;
                                    player.addHPMP(player.getStat().getCurrentMaxHp() * (skillEffect != null ? skillEffect.getX() : 3) / 100, 0, false, true);
                                }
                                break;
                            }
                            case 2: {
                                int i = max - (n3 ? 0 : 1);
                                passive = i <= 0;
                                max = passive ? (skillEffect != null ? skillEffect.getY() : 10) : i;
//                                MapleMonster.applyStatus(skillEffect != null ? skillEffect : mbsvh.getEffect(), player, monster, 8000);
                                List<MonsterStatusEffect> arrayList = new ArrayList<>();
                                arrayList.add(new MonsterStatusEffect(MonsterStatus.Poison, 1, mbsvh.getEffect().getSourceid(), null, false));
                                monster.applyStatus(player, arrayList, true, (long) mbsvh.getEffect().getDuration(), true, mbsvh.getEffect());
                                break;
                            }
                            case 3: {
                                if (Randomizer.nextInt(100) < ((skillEffect != null) ? skillEffect.getU() : 30)) {
                                    final int n11;
                                    curr = ((passive = ((n11 = curr - (n3 ? 0 : 1)) <= 0)) ? ((skillEffect != null) ? skillEffect.getZ() : 10) : n11);
                                    MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, skillEffect != null ? skillEffect : mbsvh.getEffect(), Collections.singletonList(monster.getObjectId()));
                                    player.getMap().broadcastMessage(player, forceAtom.getPacket(), true);
                                }
                                break;
                            }
                        }
                        int i = mode * 10000 + max * 100 + curr;
                        mbsvh.setValue(i);
                        mbsvh.getEffect().applyTo(player, player.getPosition(), !passive);
                    }
                }
                if (totalDamage > 0 && player.getCheatTracker().cU() && (effect = player.getSkillEffect(神射手.精神集中)) != null) {
                    effect.applyTo(player);
                }
                break;
            }
            case 321:
            case 322: {
                Optional.ofNullable(SkillFactory.getSkill(箭神.伤害置换)).ifPresent(skill -> {
                    if (player.getTotalSkillLevel(skill) > 0) {
                        player.getSkillEffect(skill.getId()).applyTo(player, true);
                    }
                });
                break;
            }
            case 410:
            case 411:
            case 412: {
                final int overrideSkillID = (player.getTotalSkillLevel(隐士.致命毒液) > 0) ? 隐士.致命毒液 : ((player.getTotalSkillLevel(隐士.武器用毒液) > 0) ? 隐士.武器用毒液 : 0);
                if (overrideSkillID > 0) {
                    final MapleStatEffect skillEffect = player.getSkillEffect(overrideSkillID);
                    if (skillEffect != null && skillEffect.makeChanceResult() && ItemConstants.isMainWeapon(player, player.getJob(), 0)) {
                        final ArrayList<MonsterStatusEffect> list = new ArrayList<>();
                        list.add(new MonsterStatusEffect(MonsterStatus.Poison, 1, overrideSkillID, null, false));
                        monster.applyStatus(player, list, true, skillEffect.getDuration(), true, skillEffect);
                    }
                }
                if (monster.getmark() && skillid != 隐士.刺客标记_飞镖 && skillid != 隐士.隐士标记_飞镖) {
                    handleAssassinStack(player, monster);
                    break;
                }
                if (!monster.getmark() && skillid != 隐士.刺客标记_飞镖 && skillid != 隐士.隐士标记_飞镖) {
                    apply刺客标记(player, monster);
                    break;
                }
                break;
            }
            case 420:
            case 421:
            case 422: {
                final MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.敛财术);
                if (monster.isAlive() && statForBuff != null && statForBuff.makeChanceResult(player)) {
                    player.getMap().spawnMesoDrop(1, monster.getPosition(), monster, player, true, (byte) 0, statForBuff.getSourceid());
                    statForBuff.applyTo(player, true);
                }
                final int skilllevel = (player.getTotalSkillLevel(侠盗.致命毒液) > 0) ? 侠盗.致命毒液 : ((player.getTotalSkillLevel(侠盗.武器用毒液) > 0) ? 侠盗.武器用毒液 : 0);
                if (skilllevel > 0) {
                    final MapleStatEffect skillEffect = player.getSkillEffect(skilllevel);
                    if (skillEffect != null && skillEffect.makeChanceResult() && ItemConstants.isMainWeapon(player, player.getJob(), 0)) {
                        final ArrayList<MonsterStatusEffect> monsterStatusEffects = new ArrayList<>();
                        monsterStatusEffects.add(new MonsterStatusEffect(MonsterStatus.Poison, 1, skilllevel, null, false));
                        monster.applyStatus(player, monsterStatusEffects, true, skillEffect.getDuration(), true, skillEffect);
                    }
                }
                if (player.getBuffedIntValue(MapleBuffStat.暴击蓄能) + player.getStat().passive_sharpeye_rate() >= 90) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.暴击蓄能);
                }
                if (skillid == 侠盗.神通术) {
                    monster.handleSteal(player);
                }
                handleKillSpreeGain(player);
                break;
            }
            case 432:
            case 434: {
                final int skil = (player.getTotalSkillLevel(双刀.致命毒液) > 0) ? 双刀.致命毒液 : ((player.getTotalSkillLevel(双刀.武器用毒液) > 0) ? 双刀.武器用毒液 : 0);
                if (skil == 0) {
                    break;
                }
                final MapleStatEffect skillEffect = player.getSkillEffect(skil);
                if (skillEffect != null && skillEffect.makeChanceResult() && ItemConstants.isMainWeapon(player, player.getJob(), 0)) {
                    final ArrayList<MonsterStatusEffect> monsterStatusEffects = new ArrayList<>();
                    monsterStatusEffects.add(new MonsterStatusEffect(MonsterStatus.Poison, 1, skil, null, false));
                    monster.applyStatus(player, monsterStatusEffects, true, skillEffect.getDuration(), true, skillEffect);
                    break;
                }
                break;
            }
            case 522: {
                Integer value = player.getBuffedValue(MapleBuffStat.神速衔接);
                if (value == null) {
                    MapleStatEffect skillEffect = player.getSkillEffect(船长.神速衔接);
                    if (skillEffect != null && Randomizer.isSuccess(skillEffect.getProp())) {
                        skillEffect.applyTo(player);
                    }
                } else if (value > 1) {
                    player.cancelBuffStats(MapleBuffStat.神速衔接);
                }
                break;
            }
            case 531: {
                if (player.getBuffedIntValue(MapleBuffStat.随机橡木桶) == 0) {
                    break;
                }
                final MapleStatEffect skillEffect = player.getSkillEffect(神炮王.随机橡木桶);
                if (skillEffect != null && skillEffect.makeChanceResult(player)) {
                    final ArrayList<MonsterStatusEffect> effects = new ArrayList<>();
                    effects.add(new MonsterStatusEffect(MonsterStatus.Poison, 1, 神炮王.随机橡木桶, null, false));
                    effects.add(new MonsterStatusEffect(MonsterStatus.Stun, 1, 神炮王.随机橡木桶, null, false));
                    effects.add(new MonsterStatusEffect(MonsterStatus.Speed, -10, 神炮王.随机橡木桶, null, false));
                    effects.add(new MonsterStatusEffect(MonsterStatus.Freeze, 1, 神炮王.随机橡木桶, null, false));
                    final int nextInt = Randomizer.nextInt(effects.size());
                    monster.applyStatus(player, effects.subList(nextInt, nextInt), true, skillEffect.getDuration(), true, skillEffect);
                    break;
                }
                break;
            }
            case 6500:
            case 6510:
            case 6511:
            case 6512: {
                MapleStatEffect statForBuff1 = player.getStatForBuff(MapleBuffStat.灵魂吸取专家);
                if (totalDamage > 0 && statForBuff1 != null && statForBuff1.makeChanceResult(player) && effect != null && effect.getSourceid() != 60011216 && effect.getSourceid() != 65111007) {
                    MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, statForBuff1, Collections.singletonList(monster.getObjectId()));
                    player.getMap().broadcastMessage(player, forceAtom.getPacket(), true);
                }
//                Skill skill = SkillFactory.getSkill(skillid);
//                if (skill != null && skill.getEffect(player.getTotalSkillLevel(SkillConstants.getLinkedAttackSkill(skillid))) != null && skillid != 爆莉萌天使.灵魂吸取_攻击 && skillid != 爆莉萌天使.灵魂吸取专家_1 && currTime - player.getStifftime() > 1500L && player.getStatForBuff(MapleBuffStat.灵魂吸取专家) != null) {
//                    final MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.灵魂吸取专家);
//                    if (statForBuff.makeChanceResult()) {
//                        player.setStifftime(currTime);
//                        final List<MapleMapObject> monstersInRange = player.getMap().getMonstersInRange(player.getTruePosition(), 100000.0);
//                        if (monstersInRange != null) {
//                            final List<Integer> moboids = new ArrayList<>();
//                            for (MapleMapObject mob : monstersInRange) {
//                                if (mob != null && !((MapleMonster) mob).getStats().isFriendly()) {
//                                    moboids.add(mob.getObjectId());
//                                }
//                            }
//                            MapleForce mapleForce = new MapleForce(player.getId(), 爆莉萌天使.灵魂吸取专家_1, 0, MapleForceType.追击盾_反射, (byte) 1, moboids, (byte) 0, statForBuff.getBulletCount(), player.getMap());
//                            player.send_other(MapleForceAtomFactory.INSTANCE.createForceAtom(player, 0, moboids, 1, statForBuff.getBulletCount(), 65120011, 300, false), true);
//                            player.send(MaplePacketCreator.updatePlayerStats(player));
//                        }
//                    }
//                }
                MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.伤害置换);
                if (statForBuff != null) {
                    final long n7 = player.getBuffedValue(MapleBuffStat.伤害置换) + totalDamage * statForBuff.getY() / 100L;
                    player.setBuffedValue(MapleBuffStat.伤害置换, (int) Math.min(Math.max(0L, n7), Math.min(99999, player.getStat().getMaxHp())));
                    player.updateBuffEffect(statForBuff, Collections.singletonMap(MapleBuffStat.伤害置换, (int) n7));
                }
                if (skillid == 爆莉萌天使.爱星能量) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.爱星能量);
                    player.handle无敌(effect, effect.getZ());
                    break;
                }
                break;
            }
            case 1300:
            case 1310:
            case 1311:
            case 1312: {
                switch (skillid) {
                    case 13100022:
                    case 13100027:
                    case 13110022:
                    case 13110027:
                    case 13111020:
                    case 13120003:
                    case 13120010:
                    case 13121054: {
                        return;
                    }
                }
                handle暴风灭世(player, monster.getObjectId());
                break;
            }
            case 1400:
            case 1410:
            case 1411:
            case 1412: {
                MapleStatEffect skillEffect = player.getSkillEffect(夜行者.影子蝙蝠_召唤兽);
                if (player.getBuffedIntValue(MapleBuffStat.影子蝙蝠) > 0) {
                    boolean spawn = false;
                    int n9 = 0;
                    List<MapleSummon> summons = new LinkedList<>(player.getSummons());
                    for (final MapleSummon summon : summons) {
                        if (summon.getSkillId() == 夜行者.影子蝙蝠_召唤兽) {
                            ++n9;
                            if (spawn || !skillEffect.makeChanceResult(player)) {
                                continue;
                            }
                            player.send_other(SummonPacket.summonSkill(summon.getOwnerId(), summon.getObjectId(), 0), true);
                            MapleForce mapleForce = new MapleForce(player.getId(), 夜行者.影子蝙蝠_攻击, 0, MapleForceType.影子蝙蝠, (byte) 2, Collections.singletonList(monster.getObjectId()), (byte) 0, 1, player.getMap());
                            player.send_other(mapleForce.writePacket(summon.getTruePosition()), true);
                            player.cancelEffect(skillEffect, false, summon.getStartTime());
                            spawn = true;
                        }
                    }
                    if (skillid == 夜行者.双飞斩 || skillid == 夜行者.三连环光击破 || skillid == 夜行者.四连镖 || skillid == 夜行者.暗影大风车 || skillid == 夜行者.五倍投掷) {
                        player.setBuffValue(player.getBuffValue() + 1);
                    }
                    if (player.getBuffValue() >= 3 && n9 < skillEffect.getBulletCount(player)) {
                        skillEffect.applyTo(player);
                        player.setBuffValue(0);
                    }
//                    if (player.getBuffedValue(MapleBuffStat.元素黑暗) != null) {
//                        MapleStatEffect eff = player.getStatForBuff(MapleBuffStat.元素黑暗);
//                        monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.ElementDarkness, 1, 夜行者.元素_黑暗, null, false, 0), true, eff.getDuration(), true, eff);
//                    }
                }
//                skillEffect = player.getStatForBuff(MapleBuffStat.SpinesOfShadow);
//                if (skillEffect != null && monster.isAlive() && effect != null && effect.getSourceid() != 14121003 && effect.getSourceid() != 400040008) {  //&& o.getCheatTracker().bD(3)
//                    spawnMist(player.getSkillEffect(400040008), player, monster.getPosition());
//                }
                break;
            }
            case 1500:
            case 1510:
            case 1511:
            case 1512: {
                handle元素雷电(player, skillid);
                break;
            }
            case 1200:
            case 1210:
            case 1211:
            case 1212: {
                final MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.引燃);
                if (statForBuff != null) {
                    for (final Map.Entry<MonsterStatus, Integer> entry : statForBuff.getMonsterStati().entrySet()) {
                        monster.applyStatus(player, new MonsterStatusEffect(entry.getKey(), entry.getValue(), statForBuff.getSourceid(), null, false), statForBuff.isPoison(), statForBuff.getDuration(), true, statForBuff);
                    }
                    break;
                }
                break;
            }
            case 2100:
            case 2110:
            case 2111:
            case 2112: {
                MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.属性攻击);
                if (statForBuff != null && !monster.isBoss()) {
                    monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.AddDamParty, statForBuff.getW(), statForBuff.getSourceid(), null, false), false, statForBuff.getY() * 1000, true, statForBuff);
                    monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.Speed, -1, statForBuff.getSourceid(), null, false), false, statForBuff.getY() * 1000, true, statForBuff);
                }
                statForBuff = player.getStatForBuff(MapleBuffStat.战神抗压);
                if (statForBuff != null && statForBuff.makeChanceResult() && !monster.isBuffed(MonsterStatus.BodyPressure)) {
                    monster.applyStatus(player, new MonsterStatusEffect(MonsterStatus.BodyPressure, 1, statForBuff.getSourceid(), null, false), false, statForBuff.getX() * 1000, true, statForBuff);
                    break;
                }
                break;
            }
            case 2005:
            case 2500:
            case 2510:
            case 2511:
            case 2512: {
                if (player.getSkillLevel(隐月.弱化) > 0) {
                    player.getSkillEffect(隐月.弱化).applyMonsterBuff(player);
                }
                if (player.getBuffedIntValue(MapleBuffStat.灵狐) > 0 && skillid != 隐月.火狐灵_1 && skillid != 隐月.狐灵_1) {
                    final int overskill = (player.getTotalSkillLevel(隐月.火狐灵) > 0) ? 隐月.火狐灵 : 隐月.狐灵;
                    MapleStatEffect skillEffect = player.getSkillEffect(overskill);
                    if (skillEffect.makeChanceResult(player)) {
                        final List<MapleMapObject> monsters = player.getMap().getMonstersInRange(player.getTruePosition(), 100000.0);
                        final ArrayList<Integer> mobids = new ArrayList<>();
                        monsters.forEach(mapObject -> {
                            final MapleMonster mob = (MapleMonster) mapObject;
                            if (!mob.getStats().isFriendly() && !mob.isFake()) {
                                mobids.add(mapObject.getObjectId());
                            }
                        });
                        MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, skillEffect, mobids);
                        player.send_other(forceAtom.getPacket(), true);
                    }
                }
                if (skillid == 隐月.分魂斩 && monster.isAlive()) {
                    final boolean buffed = monster.isBuffed(MonsterStatus.SeperateSoulP);
                    final boolean buffed2 = monster.isBuffed(MonsterStatus.SeperateSoulC);
                    if ((!buffed || monster.getBuff(MonsterStatus.SeperateSoulP).getMoboid() <= 0) && (!buffed2 || monster.getBuff(MonsterStatus.SeperateSoulC).getMoboid() <= 0)) {
                        MonsterStatusEffect oldeffect = new MonsterStatusEffect(MonsterStatus.AddDamSkil, effect.getX(), skillid, null, false);
                        if (monster.getStats().isMobile()) {
                            final MapleMonster nmonster = new MapleMonster(monster);
                            nmonster.setHp(monster.getHp());
                            player.getMap().spawnMonsterOnGroundBelow(nmonster, monster.getPosition());
                            final MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(MonsterStatus.SeperateSoulC, effect.getX(), skillid, null, false);
                            monsterStatusEffect.setMoboid(monster.getObjectId());
                            nmonster.applyStatus(player, monsterStatusEffect, false, effect.getDuration(player), false, effect);
                            oldeffect = new MonsterStatusEffect(MonsterStatus.SeperateSoulP, effect.getX(), skillid, null, false);
                            oldeffect.setMoboid(nmonster.getObjectId());
                        }
                        monster.applyStatus(player, oldeffect, false, effect.getDuration(player), false, effect);
                    }
                    break;
                }
                MapleStatEffect skillEffect = player.getSkillEffect(隐月.精灵凝聚第1招);
                if (skillEffect != null && totalDamage > 0) {
                    player.addHP(((int) Math.min(monster.getMobMaxHp(), Math.min(((int) ((double) totalDamage * (double) skillEffect.getX() / 100.0)), player.getStat().getMaxHp() / 2))));
                }
                break;
            }
            case 3610:
            case 3611:
            case 3612: {
                player.addPowerCount(1);
                if (monster.isAlive() && monster.getTriangulation() >= 3 && monster.isBuffed(MonsterStatus.Explosion)) {
                    monster.setTriangulation(0);
                    monster.cancelStatus(MonsterStatus.Explosion);
                    monster.cancelStatus(MonsterStatus.EVA);
                    monster.cancelStatus(MonsterStatus.Blind);
                    player.send(ForcePacket.UserExplosionAttack(monster));
                    break;
                }
                player.handelTriangulation(monster);
                break;
            }
            case 2410:
            case 2411:
            case 2412: {
                if (skillid == 幻影.玫瑰卡片终结) {
                    monster.getMap().spawnMist(new MapleMist(MapleStatEffectFactory.calculateBoundingBox(effect, monster.getTruePosition(), player.isFacingLeft()), player, effect, monster.getPosition()), effect.getDuration(), false);
                }
                if (skillid / 1000000 != 400 && skillid % 10000 / 1000 >= 1 && skillid != 幻影.黑色秘卡 && skillid != 幻影.卡片雪舞) {
                    handleCarteGain(player, monster.getObjectId(), false);
                    break;
                }
                break;
            }
            case 2700:
            case 2710:
            case 2711:
            case 2712: {
                if (skillid > 0) {
                    handleLuminous(player, skillid);
                }
                if (player.getJob() == 2712) {
                    handleDarkCrescendo(player);
                }
                handleBlackBless(player);
                break;
            }
            case 3300:
            case 3310:
            case 3311:
            case 3312: {
//                if (getStatForBuff(MapleBuffStat.召唤美洲豹) != null && !getJaguraAttack()) {
//                    JaguraAttack(true);
//                }
                if (skillid == 豹弩游侠.美洲豹灵魂) {
                    if (effect.makeChanceResult()) {
                        monster.applyStatus(player, effect.getMonsterStatus(), false, effect.getDuration(), true, effect);
                    }
                }
                if (SkillConstants.is美洲豹(skillid)) {
                    if (effect.makeChanceResult()) {
                        Objects.requireNonNull(SkillFactory.getSkill(33000036)).getEffect(1).applyMonsterBuff(monster, player);
                    }
                }
                if (monster.isAlive() && monster.isBuffed(MonsterStatus.JaguarBleeding) && SkillConstants.isJaguraLinkedAttack(skillid)) {
                    player.send(MaplePacketCreator.userBonusAttackRequest(33000036, monster.getBuff(MonsterStatus.JaguarBleeding).getCount(), Collections.singletonList(monster.getObjectId())));
                    break;
                }
                break;
            }
            case 3001:
            case 3110:
            case 3111:
            case 3112: {
                final MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.吸血鬼之触);
                if (skillid > 0L && statForBuff != null) {
                    int min = (int) Math.min(monster.getMobMaxHp(), skillid) * statForBuff.getX() / 100;
                    if (min > 0) {
                        if (player.getParty() != null) {
                            for (final MaplePartyCharacter mc : player.getParty().getMembers()) {
                                if (mc != null && mc.isOnline() && mc.getMapid() == player.getMapId() && mc.getChr() != null && mc.getChr().canCRecover(System.currentTimeMillis(), statForBuff.getY() * 1000)) {
                                    min = Math.min(mc.getChr().getStat().getCurrentMaxHp() * statForBuff.getW() / 100, min);
                                    mc.getChr().healHP(min);
                                    mc.getChr().prepareCRecovery();
                                }
                            }
                        } else if (player.canCRecover(System.currentTimeMillis(), statForBuff.getY())) {
                            player.prepareRecovery();
                            player.healHP(min);
                        }
                    }
                    break;
                }
                if (!SkillConstants.isForceIncrease(skillid)) {
                    return;
                }
                int n13 = skillid == 31121052 ? 15 : Randomizer.nextInt(5) + 1;
                MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, monster.getObjectId());
                player.send_other(forceAtom.getPacket(), true);
                MapleStatEffect effect_ex = player.getSkillEffect(31110009);
                if (effect_ex != null && effect_ex.makeChanceResult(player)) {
                    forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, monster.getObjectId());
                    player.send_other(forceAtom.getPacket(), true);
                }
                player.addHPMP(0, n13, false);
                if (n13 >= 50) {
                    player.reduceCooldown(31121054, 3000);
                }
                break;
            }
            case 3200:
            case 3210:
            case 3211:
            case 3212: {
//                MapleStatEffect effect = getStatForBuff(MapleBuffStat.死亡契约);
//                if (effect != null && (!monster.isAlive() || getBuffValue() + 1 > effect.getX() || monster.isBoss())) {
//                    int x = getBuffValue() + 1;
//                    final long n12 = (effect.getSourceid() == 32001014) ? 9L : ((effect.getSourceid() == 32100010) ? 8L : ((effect.getSourceid() == 32110017) ? 6L : 5L));
//                    if (x > effect.getX() || (getBuffedIntValue(MapleBuffStat.战斗大师) > 0 && x > 3)) {
//                        if (System.currentTimeMillis() - getStifftime() >= n12 * 1000L) {
//                            send(SummonPacket.summonSkillLink(getId(), getSummonOid()));
//                            x = 0;
//                            setStifftime(System.currentTimeMillis());
//                        }
//                        else {
//                            x = effect.getX();
//                        }
//                    }
//                    setBuffValue(x);
//                    updateBuffEffect(effect, Collections.singletonMap(MapleBuffStat.死亡契约, x));
//                }
                handleDeathPact(player, monster.getObjectId(), true);
                MapleStatEffect skillEffect = player.getSkillEffect(唤灵斗师.吸收灵气);
                if (skillEffect != null && !monster.isAlive()) {
                    player.addHP((int) (player.getStat().getCurrentMaxHp() * (skillEffect.getKillRecoveryR() / 100.0)));
                }
                skillEffect = player.getSkillEffect(唤灵斗师.黑暗闪电);
                if (skillEffect != null && (skillid == 唤灵斗师.黑暗锁链 || skillid == 唤灵斗师.斗战突击)) {
                    final ArrayList<MonsterStatusEffect> list9 = new ArrayList<>();
                    list9.add(new MonsterStatusEffect(MonsterStatus.DarkLightning, skillEffect.getX(), 32110020, null, false));
                    monster.applyStatus(player, list9, false, skillEffect.getY() * 1000, true, skillEffect);
                }
                if (monster.isAlive() && monster.isBuffed(MonsterStatus.DarkLightning) && skillid != 唤灵斗师.黑暗锁链 && skillid != 唤灵斗师.斗战突击 && skillid != 唤灵斗师.黑暗闪电) {
                    player.send(MaplePacketCreator.userBonusAttackRequest(32110020, monster.getBuff(MonsterStatus.DarkLightning).getCount(), Collections.singletonList(monster.getObjectId())));
                    monster.cancelStatus(MonsterStatus.DarkLightning);
                    break;
                }
                break;
            }
            case 4001:
            case 4100:
            case 4111:
            case 4112: {
//                if (getBuffedIntValue(MapleBuffStat.拔刀术加成) > 0) {
//                    handleHayatoPoint(2);
//                }
                final int skil = (player.getSkillLevel(剑豪.红莲咒缚) > 0) ? 剑豪.红莲咒缚 : ((player.getSkillLevel(剑豪.红咒缚) > 0) ? 剑豪.红咒缚 : 0);
                if (player.getSkillLevel(skil) <= 0) {
                    break;
                }
                final MapleStatEffect skillEffect = player.getSkillEffect(skil);
                if (skillEffect.makeChanceResult()) {
                    final ArrayList<MonsterStatusEffect> list10 = new ArrayList<>();
                    list10.add(new MonsterStatusEffect(MonsterStatus.Burned, (int) monster.getHp() * skillEffect.getDOT() / 100, skillEffect.getSourceid(), null, false));
                    monster.applyStatus(player, list10, true, skillEffect.getDOTTime() * 1000, true, skillEffect);
                    break;
                }
                break;
            }
            case 4002:
            case 4200:
            case 4211:
            case 4212: {
                if (skillid == 阴阳师.召唤妖云) {
                    if (Randomizer.nextInt(100) < 50) {
                        monster.getMap().spawnMist(new MapleMist(MapleStatEffectFactory.calculateBoundingBox(effect, monster.getTruePosition(), player.isFacingLeft()), player, effect, monster.getPosition()), effect.getDuration(), false);
                    }
                }
                if (player.getSkillLevel(阴阳师.朱玉的咒印) > 0 && skillid != 阴阳师.朱玉的咒印 && monster.getBeadJade() < (monster.isBoss() ? 15 : 10)) {
                    final Skill skill = SkillFactory.getSkill(阴阳师.朱玉的咒印);
                    if (skill.getEffect(player.getSkillLevel(skill)).makeChanceResult()) {
                        final Item item = new Item(4033270, (byte) 0, (short) 1);
                        monster.setBeadJade(Math.min(monster.isBoss() ? 15 : 10, monster.getBeadJade() + 1));
                        monster.getMap().spawnMobDrop(item, monster.getPosition(), monster, player, (byte) 0, 0, 阴阳师.朱玉的咒印);
                    }
                }
                if (skillid == 阴阳师.紫扇仰波 || skillid == 42001005) {
                    final MapleStatEffect skillEffect = player.getSkillEffect((skillid == 阴阳师.紫扇仰波) ? 阴阳师.紫扇仰波_焰 : 42111006);
                    if (skillEffect != null) {
                        skillEffect.applyMonsterBuff(player);
                    }
                }
                if (!monster.isAlive() && player.getSkillLevel(阴阳师.吸生缠气) > 0) {
                    player.getSkillEffect(阴阳师.吸生缠气).applyTo(player);
                }
                if (skillid == 阴阳师.朱玉的咒印) {
                    monster.getMap().removeDrop(4033270);
                }
                break;
            }
            case 10000:
            case 10100:
            case 10110:
            case 10111:
            case 10112: {
                MapleStatEffect skillEffect = player.getSkillEffect(神之子.提速时刻);
                if (skillEffect != null && currTime - player.getStifftime() > 1000L) {
                    skillEffect.applyTo(player);
                    player.setStifftime(System.currentTimeMillis());
                }
                skillEffect = player.getSkillEffect(神之子.圣光照耀);
                if (skillEffect != null && skillEffect.makeChanceResult() && !player.isZeroSecondLook()) {
                    for (final Map.Entry<MonsterStatus, Integer> entry : skillEffect.getMonsterStati().entrySet()) {
                        monster.applyStatus(player, new MonsterStatusEffect(entry.getKey(), entry.getValue(), skillEffect.getSourceid(), null, false), skillEffect.isPoison(), skillEffect.getDuration(), true, skillEffect);
                    }
                }
                skillEffect = player.getSkillEffect(神之子.防甲瓦解);
                if (skillEffect != null && skillEffect.makeChanceResult() && player.isZeroSecondLook()) {
                    for (final Map.Entry<MonsterStatus, Integer> entry : skillEffect.getMonsterStati().entrySet()) {
                        monster.applyStatus(player, new MonsterStatusEffect(entry.getKey(), entry.getValue(), skillEffect.getSourceid(), null, false), skillEffect.isPoison(), skillEffect.getDuration(), true, skillEffect);
                    }
                    break;
                }
                break;
            }
            case 13000:
            case 13100: {
                if (player.getBuffedIntValue(MapleBuffStat.嗨兄弟) <= 0) {
                    break;
                }
                final MapleStatEffect skillEffect = player.getSkillEffect(131002015);
                if (skillEffect.makeChanceResult(player)) {
                    skillEffect.applyTo(player);
                    break;
                }
                break;
            }
            case 14211:
            case 14212: {
                final int linkedAttackSkill = SkillConstants.getLinkedAttackSkill(skillid);
                if (linkedAttackSkill == 超能力者.心灵传动 || linkedAttackSkill == 超能力者.心魂之力 || linkedAttackSkill == 超能力者.心魂之力2 || linkedAttackSkill == 超能力者.心魂之力3 || linkedAttackSkill == 超能力者.心魂释放 || linkedAttackSkill == 超能力者.心魂吸收 || linkedAttackSkill == 超能力者.终极_心魂弹 || linkedAttackSkill == 超能力者.终极_物质 || linkedAttackSkill == 超能力者.终极_深层冲击 || linkedAttackSkill == 超能力者.终极_火车 || linkedAttackSkill == 超能力者.终极_BPM) {
                    break;
                }
                handlerKSTelekinesis(player, monster.getObjectId());
                break;
            }
        }
//        if (JobConstants.is神之子(o.getJob())) {
//            if (g != null && g.getSourceID() == 400011015 && n > 0L) {
//                final com.cms.k.e.q map2 = o.getMap();
//                final int objectID2 = l.getObjectID();
//                final int id2 = o.getID();
//                final int n14 = objectID2;
//                final com.cms.g.d.b.b b4;
//                (b4 = new com.cms.g.d.b.b()).a(com.cms.g.c.c.aZH);
//                b4.writeInt(n14);
//                b4.writeInt(1);
//                b4.writeInt(400011024);
//                b4.writeShort(100);
//                b4.writeInt(id2);
//                b4.write(1);
//                map2.broadcastMessage(o, b4.kr(), true);
//            }
//            if (!o.isBeta()) {
//                final g skillEffect21 = o.getSkillEffect(101120207);
//                if (n > 0L && skillEffect21 != null) {
//                    a(skillEffect21, o, l, skillEffect21.A(o));
//                }
//            }
//            else {
//                if (g != null && g.getSourceID() == 101000101) {
//                    o.getClient().a(com.cms.g.a.a.a(o.getPosition(), 101000101, Collections.singletonList(101000102)));
//                }
//                final g skillEffect22 = o.getSkillEffect(101120110);
//                if (n > 0L && skillEffect22 != null) {
//                    a(skillEffect22, o, l, skillEffect22.A(o));
//                }
//                final g skillEffect23 = o.getSkillEffect(101110103);
//                if (n > 0L && skillEffect23 != null) {
//                    a(skillEffect23, o, l, skillEffect23.A(o));
//                }
//            }
//        }
        if (JobConstants.is魔链影士(player.getJob())) {
            if (player.getStatForBuff(MapleBuffStat.锁链术_狂怒) != null && player.getCheatTracker().cw()) {
                final Point position3 = monster.getPosition();
                MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
                mplew.writeShort(SendPacketOpcode.CHAIN_RAGE_ACTION.getValue());
                mplew.writePosAsInt(position3);
                player.getClient().announce(mplew.getPacket());
            }
            if (effect != null && effect.getSourceid() == 魔链影士.锁链术_追逐_3 && monster != null) {
                player.getClient().announce(EffectPacket.showBuffeffect(null, 魔链影士.锁链术_追逐_3, 1, effect.getLevel(), monster.getObjectId(), (byte) 3, monster.getPosition()));
                player.getMap().broadcastMessage(player, EffectPacket.showBuffeffect(player, 魔链影士.锁链术_追逐_3, 1, effect.getLevel(), monster.getObjectId(), (byte) 3, player.getPosition()), monster.getPosition());
            }
        }
    }

    /*
     * 斗气集中效果处理
     */
    public static void handleOrbgain(MapleCharacter player, boolean passive) {
        //检测当前是否有斗气集中的BUFF效果
        if (player.getBuffedValue(MapleBuffStat.斗气集中) == null) {
            return;
        }
        //获取当前的斗气点数
        int orbcount = player.getBuffedValue(MapleBuffStat.斗气集中);
        Skill combo_2 = SkillFactory.getSkill(英雄.斗气集中);
        Skill combo_3 = SkillFactory.getSkill(英雄.斗气协合);
        Skill combo_4 = SkillFactory.getSkill(英雄.进阶斗气);
        if (passive && player.getTotalSkillLevel(combo_3) <= 0) {
            return;
        }
        MapleStatEffect effect;
        if (player.getTotalSkillLevel(combo_3) > 0) {
            effect = combo_3.getEffect(player.getTotalSkillLevel(combo_3));
        } else if (player.getTotalSkillLevel(combo_2) > 0) {
            effect = combo_2.getEffect(player.getTotalSkillLevel(combo_2));
        } else {
            return;
        }
        int neworbcount = orbcount;
        if (effect != null && orbcount < effect.getX() + 1) {
            if (!passive && effect.makeChanceResult()) {
                neworbcount++;
            }
            if (passive && Randomizer.nextInt(100) < effect.getSubProp()) {
                neworbcount++;
            }
        }
        //进阶斗气有概率多增加1点斗气
        if (player.getTotalSkillLevel(combo_4) > 0 && !passive) {
            effect = combo_4.getEffect(player.getTotalSkillLevel(combo_4));
            if (effect != null && effect.makeChanceResult() && neworbcount < effect.getX() + 1) {
                neworbcount++;
            }
        }
        if (effect != null) {
            if (neworbcount != orbcount) {
                Map<MapleBuffStat, Integer> stat = Collections.singletonMap(MapleBuffStat.斗气集中, neworbcount);
                player.setBuffedValue(MapleBuffStat.斗气集中, neworbcount);
                int duration = effect.getDuration();
                duration += (int) ((player.getBuffedStartTime(MapleBuffStat.斗气集中) - System.currentTimeMillis()));
                player.getClient().announce(BuffPacket.giveSingleBuff(combo_2.getId(), duration, stat, effect, player));
                player.getMap().broadcastMessage(player, BuffPacket.giveForeignBuff(player, stat, effect), false);
            }
        }
    }

    /**
     * 处理攻击怪物触发
     */
    public static void afterAttack(MapleCharacter player, MapleStatEffect attackeffect, int mobCount, int attackCount, int skillid) {
        final PlayerStats stat = player.getStat();
        final PlayerSpecialStats specialStat = player.getSpecialStat();
        int job = player.getJob();
        /*HP恢复机率*/
        if (stat.hpRecoverProp > 0 && Randomizer.nextInt(100) <= stat.hpRecoverProp) {
            if (stat.hpRecover > 0) {
                player.healHP(stat.hpRecover);
            }
            /*HP恢复百分比*/
            if (stat.hpRecover_Percent > 0) {
                /*角色增加HP*/
                player.addHPMP((int) ((double) stat.getCurrentMaxHp() * (double) stat.hpRecover_Percent / 100.0) * mobCount, 0, false);
            }
        }
        /*MP恢复机率*/
        if (stat.mpRecoverProp > 0 && !JobConstants.isNotMpJob(job) && Randomizer.nextInt(100) <= stat.mpRecoverProp) {
            if (stat.mpRecover > 0) {
                player.healMP(stat.mpRecover);
            }
        }

        switch (job) {
            case 120:
            case 121:
            case 122: {
                handleElementalCharge(player, skillid);
                break;
            }
            case 421:
            case 422: {
                //处理激活刀飞幸运钱的再次使用
                if (player.getSkillLevel(侠盗.幸运钱) > 0 && Randomizer.isSuccess(player.getStat().passive_sharpeye_rate)) {
                    switchLuckyMoney(player, true);
                }
                MapleStatEffect ds = player.getStatForBuff(MapleBuffStat.隐身术);
                if (ds != null && ds.getSourceid() == 飞侠.隐身术 && (ds = player.getSkillEffect(侠盗.进阶隐身术)) != null && !ds.makeChanceResult()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.隐身术);
                }
                break;
            }
            case 510:
            case 511:
            case 512:
                if (!specialStat.isEnergyFull()) {
                    handleEnergyCharge(player, mobCount * 2, false);
                } else {
                    handleEnergyConsume(player, mobCount, skillid);
                }
                break;
            case 110:
            case 111:
            case 112:
            case 2411: //添加幻影职业 幻影复制技能后有这个
            case 2412:
                if (skillid != 英雄.虎咆哮 & player.getBuffedValue(MapleBuffStat.斗气集中) != null) {
                    handleOrbgain(player, false);
                }
                break;
            case 6100:
            case 6110:
            case 6111:
            case 6112:
                int amon = 0;
                switch (skillid) {
                    case 狂龙战士.扇击:
                    case 狂龙战士.扇击_变身:
                        amon = 1;
                        break;
                    case 狂龙战士.飞龙斩_2:
                    case 狂龙战士.烈火箭:
                        amon = 2;
                        break;
                    case 狂龙战士.冲击波:
                    case 狂龙战士.穿刺冲击:
                        amon = 3;
                        break;
                    case 狂龙战士.牵引锁链:
                    case 狂龙战士.怒雷屠龙斩:
                    case 狂龙战士.天空剑影:
                    case 狂龙战士.剑气突袭:
                        amon = 5;
                        break;
                    case 狂龙战士.剑刃之壁:
                    case 狂龙战士.进阶剑刃之壁:
                        amon = 20;
                        break;
                    case 狂龙战士.恶魔之息:
                        amon = 40;
                        break;
                }
                if (skillid == 61121105) {
                    Skill skill = SkillFactory.getSkill(skillid);
                    MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(skill));
                    player.getMap().spawnMist(new MapleMist(MapleStatEffectFactory.calculateBoundingBox(effect, player.getPosition(), player.isFacingLeft()), player, effect, player.getPosition()), effect.getDuration(), false);
                }
                if (amon > 0) {
                    handleMorphCharge(player, amon);
                }
                break;
            case 312: {
                if (player.getBuffSource(MapleBuffStat.IndieSummoned) == 神射手.箭雨) {
                    Optional.ofNullable(SkillFactory.getSkill(神射手.箭雨)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(神射手.箭雨);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is神射手(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getX() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(神射手.箭雨_1, 0, Collections.emptyList()));
                        }
                    });
                }
                break;
            }
            case 1112: {
                if (player.getBuffSource(MapleBuffStat.IndieSummoned) == 魂骑士.天人之舞) {
                    Optional.ofNullable(SkillFactory.getSkill(魂骑士.天人之舞)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(魂骑士.天人之舞);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        int value = player.getBuffedIntValue(MapleBuffStat.月光转换);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is魂骑士(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getS2() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(value == 1 ? 魂骑士.天人之舞_1 : 魂骑士.天人之舞_2, 0, Collections.emptyList()));
                        }
                    });
                }
                if (attackeffect != null && attackeffect.getSourceid() == 魂骑士.往生极乐_冥河破) {
                    final MapleSummon summonBySkillID = player.getSummonBySkillID(魂骑士.往生极乐_Summon);
                    if (summonBySkillID != null) {
                        final Rectangle a = MapleStatEffectFactory.calculateBoundingBox(attackeffect, player.getPosition(), player.isFacingLeft(), 500);
                        if (summonBySkillID.getBounds().contains(a) || summonBySkillID.getBounds().intersects(a)) {
                            summonBySkillID.setCharge(summonBySkillID.getCharge() + 1);
                            final MapleMap map = player.getMap();
                            map.broadcastMessage(player, SummonPacket.SummonedCrossTheStyx(summonBySkillID, 1), true);
                        }
                        return;
                    }
                    player.getSkillEffect(魂骑士.往生极乐_Summon).applyTo(player, new Point(player.getPosition().x + (player.isFacingLeft() ? -100 : 100), player.getPosition().y));
                }
                break;
            }
            case 2112: {
                if (player.getBuffSource(MapleBuffStat.IndieSummoned) == 战神.装备摩诃) {
                    Optional.ofNullable(SkillFactory.getSkill(战神.装备摩诃)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(战神.装备摩诃);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is战神(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getX() * 1000));
                            player.send(MaplePacketCreator.userBonusAttackRequest(战神.装备摩诃_1, 0, Collections.emptyList()));
                        }
                    });
                }
                break;
            }
            case 2312: {
                if (player.getBuffSource(MapleBuffStat.IndieSummoned) == 双弩.精灵元素) {
                    Optional.ofNullable(SkillFactory.getSkill(双弩.元素幽灵_3)).ifPresent(skill -> {
                        int totalSkillLevel = player.getTotalSkillLevel(双弩.精灵元素);
                        MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                        if (totalSkillLevel > 0 && effect != null && JobConstants.is双弩精灵(skillid / 10000) && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                            Optional.ofNullable(SkillFactory.getSkill(双弩.精灵元素)).ifPresent(skill1 -> {
                                player.setLastUseVSkillTime(player.isSuperGM() ? 0 : System.currentTimeMillis() + (long) (skill1.getEffect(totalSkillLevel).getS2() * 1000));
                                player.send(MaplePacketCreator.userBonusAttackRequest(双弩.元素幽灵_3, 0, Collections.emptyList()));
                            });
                        }
                    });
                }
                break;
            }
            default:
                if (!player.isIntern()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.风影漫步);
                    player.cancelEffectFromBuffStat(MapleBuffStat.潜入状态);
                    MapleStatEffect ds = player.getStatForBuff(MapleBuffStat.隐身术);
                    if (ds != null) {
                        if (job == 433 || job == 434) {
                            if (ds.getSourceid() == 飞侠.终极隐身术) {
                                break;
                            }
                            Optional.ofNullable(SkillFactory.getSkill(双刀.进阶隐身术).getEffect(player.getTotalSkillLevel(双刀.进阶隐身术))).ifPresent(effect -> {
                                if (!effect.makeChanceResult()) {
                                    player.cancelEffectFromBuffStat(MapleBuffStat.隐身术);
                                }
                            });
                        }
                    }
                }
                if (JobConstants.is尖兵(job)) {
                    if (player.getBuffedValue(MapleBuffStat.精准火箭) != null) {
                        handleCardStack(player, skillid);
                    }
                } else if (JobConstants.is风灵使者(job)) {
                    MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.狂风肆虐);
                    if (effect != null) {
                        List<MapleMapObject> list = player.getMap().getMapObjectsInRect(MapleStatEffectFactory.calculateBoundingBox(effect, player.getPosition(), player.isFacingLeft(), 500), Collections.singletonList(MapleMapObjectType.MONSTER));
                        ArrayList<Integer> arrayList = new ArrayList<>();
                        list.forEach(s2 -> arrayList.add(s2.getObjectId()));
                        MapleStatEffect skillEffect = player.getSkillEffect(13110022);
                        if (skillEffect != null) {
                            effect = skillEffect;
                        }
                        if ((skillEffect = player.getSkillEffect(13120003)) != null) {
                            effect = skillEffect;
                        }
                        if (arrayList.isEmpty() || effect.getSourceid() == SkillConstants.getLinkedAttackSkill(skillid)) {
                            return;
                        }
                        if (!effect.makeChanceResult(player)) {
                            if (Randomizer.nextInt(100) <= effect.getInfo().get(MapleStatInfo.subProp)) {
                                MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, arrayList);
                                player.getMap().broadcastMessage(player, forceAtom.getPacket(), true);
                            }
                            return;
                        }
                        skillEffect = player.getSkillEffect(effect.getSourceid() == 13120003 ? effect.getSourceid() + 7 : effect.getSourceid() + 5);
                        if (skillEffect != null) {
                            MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, skillEffect, arrayList);
                            player.getMap().broadcastMessage(player, forceAtom.getPacket(), true);
                            return;
                        }
                    }
                    handle狂风肆虐(player, skillid);
                } else if (JobConstants.is夜光(job)) {
                    handleLuminous(player, skillid); //夜光光暗点数处理
                    if (player.getJob() == 2712) {
                        handleDarkCrescendo(player); //夜光黑暗高潮处理
                    }
                    handleBlackBless(player); //夜光黑暗祝福处理
                } else if (JobConstants.is恶魔复仇者(job)) {
                    handle超越状态(player, skillid);
                } else if (JobConstants.is爆破手(job)) {
                    if (skillid == 爆破手.碎骨巨叉) {
                        player.send(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), 爆破手.碎骨巨叉, Collections.singletonList(爆破手.碎骨巨叉_1)));
                    }
                    if (skillid == 爆破手.神圣狂暴打击) {
                        player.send(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), 爆破手.神圣狂暴打击, Collections.singletonList(爆破手.神圣狂暴打击_2)));
                    }
                    if (skillid == 爆破手.旋转弹) {
                        player.send(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), 爆破手.旋转弹, Collections.singletonList(爆破手.旋转弹_7)));
                    }
//                    hadnleChargeBlaster(player);
                    return;
                } else if (JobConstants.is龙神(job)) {
                    switch (skillid) {
                        case 龙神.元素爆破: {
                            List<Integer> list = Arrays.asList(龙神.元素爆破_1, 龙神.元素爆破_2, 龙神.元素爆破_3, 龙神.元素爆破_4);
                            player.send(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), 龙神.元素爆破, list));
                            break;
                        }
                    }
                } else if (JobConstants.is魔链影士(job)) {
                    if (attackeffect != null) {
                        MapleStatEffect g3 = player.getSkillEffect(魔链影士.武器多样化Ⅰ);
                        final int linkedAttackSkill = SkillConstants.getLinkedAttackSkill(attackeffect.getSourceid());
                        switch (linkedAttackSkill) {
                            case 魔链影士.狂袭利爪:
                            case 魔链影士.旋转飞刃:
                            case 魔链影士.召唤散弹枪:
                            case 魔链影士.凌厉双刀:
                            case 魔链影士.释放炸弹:
                            case 魔链影士.召唤狼牙棒:
                            case 魔链影士.拍板砖: {
                                final int lastSkill = player.getLastSkill();
                                if (g3 != null && SkillConstants.getLinkedAttackSkill(lastSkill) != linkedAttackSkill && SkillConstants.isChangeWeaponSkill(lastSkill)) {
                                    if (player.getSkillEffect(魔链影士.武器多样化Ⅲ) != null) {
                                        g3 = player.getSkillEffect(魔链影士.武器多样化Ⅲ);
                                    } else if (player.getSkillEffect(魔链影士.武器多样化Ⅱ) != null) {
                                        g3 = player.getSkillEffect(魔链影士.武器多样化Ⅱ);
                                    }
                                    g3.applyTo(player);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                } else if (JobConstants.is圣晶使徒(job)) {
                    final MapleStatEffect statEffect;
                    if ((statEffect = player.getStatForBuff(MapleBuffStat.荣耀之翼)) != null && attackeffect != null && attackeffect.getSourceid() != 圣晶使徒.荣耀之翼_致命展翅) {
                        statEffect.applyTo(player);
                    }
                    if (attackeffect != null && (attackeffect.getSourceid() == 圣晶使徒.反应_控制 || attackeffect.getSourceid() == 圣晶使徒.反应_控制Ⅱ)) {
                        player.addCooldown(attackeffect);
                    }
                    final MapleSummon summon1;
                    if (attackeffect != null && attackeffect.getSourceid() == 圣晶使徒.反应_光谱 && (summon1 = player.getSummonBySkillID(圣晶使徒.古代水晶)) != null) {
                        player.addCooldown(attackeffect);
                        player.getClient().announce(SummonPacket.SummonedStateChange(summon1, 3, 0, 0));
                    }
                } else if (JobConstants.is影魂异人(job)) {
                    if (attackeffect != null) {
                        switch (attackeffect.getSourceid()) {
                            case 影魂异人.纯粹念力珠:
                            case 155100009:
                            case 影魂异人.火焰念力珠:
                            case 影魂异人.疾风念力珠:
                            case 影魂异人.憎恶轨迹:
                            case 影魂异人.深渊念力珠: {
                                break;
                            }
                            default: {
                                final MapleStatEffect effecForBuffStat16;
                                if (player.getBuffedValue(MapleBuffStat.控制侵蚀) != null && (effecForBuffStat16 = player.getStatForBuff(MapleBuffStat.追魂手)) != null) {
                                    final List<MapleMapObject> mapObjectsInRect3 = player.getMap().getMapObjectsInRect(MapleStatEffectFactory.calculateBoundingBox(effecForBuffStat16, player.getPosition(), player.isFacingLeft(), 100), Collections.singletonList(MapleMapObjectType.MONSTER));
                                    final ArrayList<Integer> list3 = new ArrayList<>();
                                    mapObjectsInRect3.forEach(v3 -> list3.add(v3.getObjectId()));
                                    if (!list3.isEmpty()) {
                                        MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, player.getSkillEffect(155100009), list3);
                                        player.getMap().broadcastMessage(player, forceAtom.getPacket(), true);
                                    }
                                }
                                final MapleStatEffect skillEffect22;
                                if ((player.getLastAttackSkillId() == 影魂异人.深渊冲锋拳 || player.getLastAttackSkillId() == 影魂异人.瞬发冲锋拳) && attackeffect.getSourceid() != 影魂异人.深渊冲锋拳 && attackeffect.getSourceid() != 影魂异人.瞬发冲锋拳 && (skillEffect22 = player.getSkillEffect(155120014)) != null) {
                                    skillEffect22.applyTo(player);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    if (attackeffect != null) {
                        switch (attackeffect.getSourceid()) {
                            case 影魂异人.瞬发冲锋拳: {
                                player.addPureBeads(1);
                                break;
                            }
                            case 影魂异人.火焰冲锋拳: {
                                player.addFlameBeads(1);
                                player.getClient().announce(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), attackeffect.getSourceid(), Collections.singletonList(155101013)));
                                break;
                            }
                            case 影魂异人.疾风冲锋拳: {
                                player.addGaleBeads(1);
                                break;
                            }
                            case 影魂异人.深渊冲锋拳: {
                                player.addAbyssBeads(1);
                                player.getClient().announce(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), attackeffect.getSourceid(), Collections.singletonList(155121002)));
                                break;
                            }
                            case 影魂异人.迷魂束缚: {
                                player.getClient().announce(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), attackeffect.getSourceid(), Collections.singletonList(影魂异人.迷魂束缚_1)));
                                break;
                            }
                            case 影魂异人.混沌暴走: {
                                player.getClient().announce(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), attackeffect.getSourceid(), Collections.singletonList(155121215)));
                                break;
                            }
                            case 影魂异人.刻骨创伤: {
                                player.getClient().announce(MaplePacketCreator.RegisterExtraSkill(player.getPosition(), attackeffect.getSourceid(), Collections.singletonList(155101201)));
                                break;
                            }
                            case 影魂异人.根源记忆: {
                                final MapleStatEffect skillEffect23;
                                if ((skillEffect23 = player.getSkillEffect(影魂异人.幽灵侵蚀)) != null && player.getBuffedValue(MapleBuffStat.控制侵蚀) == null) {
                                    skillEffect23.applyTo(player);
                                }
                                break;
                            }
                        }
                    }
                }
        }

        if (JobConstants.is战士(player.getJob()) && player.getBuffedIntValue(MapleBuffStat.IndieSummoned) > 0 && player.getBuffSource(MapleBuffStat.IndieSummoned) == 战士.灵气武器) {
            Optional.ofNullable(SkillFactory.getSkill(战士.灵气武器)).ifPresent(skill -> {
                int totalSkillLevel = player.getTotalSkillLevel(战士.灵气武器);
                MapleStatEffect effect = skill.getEffect(totalSkillLevel);
                if (totalSkillLevel > 0 && effect != null && System.currentTimeMillis() >= player.getLastUseVSkillTime()) {
                    player.setLastUseVSkillTime(System.currentTimeMillis() + (long) (effect.getZ() * 1000));
                    player.send(MaplePacketCreator.userBonusAttackRequest(战士.灵气武器_1, 0, Collections.emptyList()));
                }
            });
        }
        if (skillid == 箭神.真一击要害箭 && JobConstants.is箭神(player.getJob()) && player.getBuffSource(MapleBuffStat.CursorSniping) == 箭神.真狙击) {
            int value = Math.max(0, player.getBuffedIntValue(MapleBuffStat.CursorSniping) - 1);
            if (value > 0) {
                player.setBuffedValue(MapleBuffStat.CursorSniping, value);
                player.updateBuffEffect(player.getStatForBuff(MapleBuffStat.CursorSniping), Collections.singletonMap(MapleBuffStat.CursorSniping, value));
            } else {
                Optional.ofNullable(SkillFactory.getSkill(箭神.真狙击)).ifPresent(skill -> {
                    MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(箭神.真狙击));
                    player.cancelEffectFromBuffStat(MapleBuffStat.CursorSniping);
                    player.handle无敌(effect, 2000);
                });
            }
        }
    }

    public static void afterUseSkill(MapleStatEffect effect, MapleCharacter player) {
        if (JobConstants.is魂骑士(player.getJob())) {
            if (player.getBuffedValue(MapleBuffStat.日月轮转) != null) {
                final MapleStatEffect skillEffect8;
                if (player.getBuffedValue(MapleBuffStat.日月轮转) != null && SkillConstants.getSoulMasterAttackMode(effect.getSourceid()) > 0) {
                    skillEffect8 = player.getSkillEffect((SkillConstants.getSoulMasterAttackMode(effect.getSourceid()) == 1) ? 魂骑士.日月轮转_旭日 : 魂骑士.日月轮转_月光洒落);
                    if (skillEffect8 != null) {
                        skillEffect8.applyTo(player);
                    }
                }
            }
        }
    }

    public static void handle影子分裂(MapleCharacter player, int oid, Point point) {
        Skill BuffSkill = SkillFactory.getSkill(夜行者.影子蝙蝠);
        Skill skill_1 = SkillFactory.getSkill(夜行者.影子蝙蝠);
        Skill skill_2 = SkillFactory.getSkill(夜行者.蝙蝠掌控);
        Skill skill_4 = SkillFactory.getSkill(夜行者.蝙蝠掌控Ⅲ);
        int skillLevel_1 = player.getSkillLevel(BuffSkill);
        int skillLevel_2 = player.getSkillLevel(skill_2);
        int skillLevel_4 = player.getSkillLevel(skill_4);
        if (skillLevel_1 < 0) {
            return;
        }
        MapleStatEffect effect = BuffSkill.getEffect(skillLevel_1);
        int prop = effect.getProp();

        if (skillLevel_2 > 0) {
            prop += skill_2.getEffect(skillLevel_2).getProp();
        }

        if (skillLevel_4 > 0) {
            prop += skill_2.getEffect(skillLevel_4).getProp();
        }

        if (Randomizer.nextInt(100) > prop) {
            player.getSpecialStat().gainForceCounter();
            player.getMap().broadcastMessage(ForcePacket.Show影子蝙蝠锁定(player.getId(), 夜行者.影子蝙蝠_攻击, oid, 1, point, player.getSpecialStat().getForceCounter()), player.getTruePosition());
            player.getSpecialStat().gainForceCounter();
        }
    }

    public static void handleEnergyCharge(MapleCharacter player, int targets, boolean is能量激发) {
        Skill echskill_2 = SkillFactory.getSkill(冲锋队长.能量获得);
        Skill echskill_3 = SkillFactory.getSkill(冲锋队长.超级冲击);
        Skill echskill_4 = SkillFactory.getSkill(冲锋队长.终极冲击);
        MapleStatEffect effect;
        if (player.getSkillLevel(echskill_4) > 0) {
            effect = echskill_4.getEffect(player.getTotalSkillLevel(echskill_4));
        } else if (player.getSkillLevel(echskill_3) > 0) {
            effect = echskill_3.getEffect(player.getTotalSkillLevel(echskill_3));
        } else if (player.getSkillLevel(echskill_2) > 0) {
            effect = echskill_2.getEffect(player.getTotalSkillLevel(echskill_2));
        } else {
            return;
        }
        if (targets > 0 && !player.getSpecialStat().isEnergyFull()) {
            //检测当前是否有能量获得的BUFF效果
            if (player.getBuffedValue(MapleBuffStat.能量获得) == null) {
                effect.applyEnergyBuff(player); // 注册第1次能量获得BUFF效果
                return;
            }
            //开始处理能量获得
            int energy = player.getBuffedIntValue(MapleBuffStat.能量获得); //获取当前能量的数量
            if (energy < 10000) { //处理未满能量的效果
                energy += is能量激发 ? 800 : (effect.getX() * targets);
                if (energy >= 10000) {
                    energy = 10000;
                    player.getSpecialStat().changeEnergyfull(true);
                }
                player.setBuffedValue(MapleBuffStat.能量获得, energy);
                //显示BUFF效果
                player.getClient().announce(EffectPacket.showOwnBuffEffect(effect.getSourceid(), EffectOpcode.UserEffect_SkillAffected.getValue(), player.getLevel(), effect.getLevel()));
                player.getClient().announce(BuffPacket.giveEnergyCharge(energy, effect.getSourceid(), player.getSpecialStat().isEnergyFull(), false));
                //发送给其他玩家看到的效果
                player.getMap().broadcastMessage(player, EffectPacket.showBuffeffect(player, effect.getSourceid(), EffectOpcode.UserEffect_SkillAffected.getValue(), player.getLevel(), effect.getLevel()), false);
                player.getMap().broadcastMessage(player, BuffPacket.giveForeignBuff(player, Collections.singletonMap(MapleBuffStat.能量获得, energy), effect), false);
            }
        }
    }

    /*
     * 处理拳手能量减少
     */
    public static void handleEnergyConsume(MapleCharacter player, int mobCount, int skillId) {
        //检测当前是否有能量获得BUFF
        MapleStatEffect echeffect = player.getStatForBuff(MapleBuffStat.能量获得);
        if (skillId == 0 || !player.getSpecialStat().isEnergyFull() || echeffect == null) {
            return;
        }
        Skill skill = SkillFactory.getSkill(skillId);
        int skillLevel = player.getTotalSkillLevel(SkillConstants.getLinkedAttackSkill(skillId));
        MapleStatEffect effect = skill.getEffect(skillLevel);
        if (effect == null || effect.getForceCon() <= 0 && skillId != 冲锋队长.海蛇螺旋) {
            return;
        }
        //获取当前的能量
        int energy = player.getBuffedIntValue(MapleBuffStat.能量获得);
        energy -= skillId == 冲锋队长.海蛇螺旋 ? effect.getY() : effect.getForceCon() * mobCount;
        if (energy <= 0) {
            energy = 0;
            player.getSpecialStat().changeEnergyfull(false);
        }
        player.setBuffedValue(MapleBuffStat.能量获得, energy);
        player.getClient().announce(BuffPacket.giveEnergyCharge(energy, echeffect.getSourceid(), player.getSpecialStat().isEnergyFull(), true));
        player.getMap().broadcastMessage(player, BuffPacket.giveForeignBuff(player, Collections.singletonMap(MapleBuffStat.能量获得, energy), effect), false);
    }

    public static void handleThunderAction(MapleCharacter player) {
        if (player.getBuffedIntValue(MapleBuffStat.RandAreaAttack) > 0) {
            List<MapleMapObject> list = player.getMap().getMonstersInRect(MapleStatEffectFactory.calculateBoundingBox(player.getStatForBuff(MapleBuffStat.RandAreaAttack), player.getPosition(), player.isFacingLeft()));
            if (!list.isEmpty()) {
                MapleMapObject m = list.get(Randomizer.nextInt(list.size()));
                player.send(MaplePacketCreator.userRandAreaAttackRequest(80001762, m.getObjectId(), m.getPosition()));
            }
        }
    }

    /*
     * 消耗斗气点数
     */
    public static void handleOrbconsume(MapleCharacter player, int howmany) {
        Skill combos = SkillFactory.getSkill(英雄.斗气集中);
        if (player.getSkillLevel(combos) <= 0) {
            return;
        }
        MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.斗气集中);
        if (effect == null) {
            return;
        }
        Map<MapleBuffStat, Integer> stat = Collections.singletonMap(MapleBuffStat.斗气集中, Math.max(1, player.getBuffedValue(MapleBuffStat.斗气集中) - howmany));
        player.setBuffedValue(MapleBuffStat.斗气集中, Math.max(1, player.getBuffedValue(MapleBuffStat.斗气集中) - howmany));
        int duration = effect.getDuration();
        duration += (int) ((player.getBuffedStartTime(MapleBuffStat.斗气集中) - System.currentTimeMillis()));
        player.getClient().announce(BuffPacket.giveSingleBuff(combos.getId(), duration, stat, effect, player));
        player.getMap().broadcastMessage(player, BuffPacket.giveForeignBuff(player, stat, effect), false);
    }

    /*
     * 更新夜光 光暗点数
     */
    public static void handleLuminous(MapleCharacter player, int skillId) {
        if (skillId == 夜光.记录) {
            player.removeCooldown(夜光.死亡之刃, true);
            player.removeCooldown(夜光.绝对死亡, true);
            SkillFactory.getSkill(夜光.平衡_光明).getEffect(1).applyTo(player);
            return;
        }
        int skillMode = SkillConstants.getLuminousSkillMode(skillId);

        if (skillMode < 0 || skillMode == 夜光.平衡_光明 || player.getSkillLevel(skillMode) <= 0) {
            return;
        }

        // 平衡状态不改变点数
        Integer buffvalue = player.getBuffedValue(MapleBuffStat.光暗转换);
        if (buffvalue != null && buffvalue == 2) {
            return;
        }

        int gauge;
        byte gaugetype = (byte) (skillMode == 夜光.太阳火焰 ? 1 : 2);
        int balanceid = -1;

        if (!player.hasBuffSkill(夜光.太阳火焰) && !player.hasBuffSkill(夜光.月蚀)) {
            int newskillid = gaugetype == 1 ? 夜光.月蚀 : 夜光.太阳火焰;
            SkillFactory.getSkill(newskillid).getEffect(1).applyTo(player);
            gauge = skillMode == 夜光.太阳火焰 ? 9999 : 1;
        } else {
            boolean isLightSkill = gaugetype == 1;
            boolean isLightMode = player.getBuffSource(MapleBuffStat.光暗转换) == 夜光.太阳火焰;
            boolean isApply = false;
            gauge = player.getSpecialStat().getDarkLight();
            MapleStatEffect effect = SkillFactory.getSkill(skillId).getEffect(player.getTotalSkillLevel(skillId));
            int gauge_val = (int) (effect.getGauge() * (((double) player.getStat().getGauge_x() / 100) + 1.0));
            if (gaugetype == 1 && isLightMode) {            //月蚀
                gauge = Math.min(9999, gauge + gauge_val);
                isApply = true;
            } else if (gaugetype == 2 && !isLightMode) {    //太阳
                gauge = Math.max(1, gauge - gauge_val);
                isApply = true;
            }

            if (isLightMode) {
                player.addHP(player.getStat().getMaxHp() / 100); //恢复1%的hp
            }

            if (gauge == 9999) {
                balanceid = 夜光.平衡_光明;
            } else if (gauge == 1) {
                balanceid = 夜光.平衡_黑暗;
            }

            if (isApply && balanceid > 0) {
                player.cancelBuffStats(MapleBuffStat.光暗转换);
                player.removeCooldown(夜光.死亡之刃, true);
                player.removeCooldown(夜光.绝对死亡, true);
                SkillFactory.getSkill(balanceid).getEffect(1).applyTo(player);
            }
        }
        //更新光暗点数
        player.getSpecialStat().setDarkLight(gauge);
        player.getClient().announce(BuffPacket.updateLuminousGauge(gauge, gaugetype));
    }

    /*
     * 夜光黑暗祝福处理
     */
    public static void handleBlackBless(MapleCharacter player) {
        if (player.getLastBlessOfDarknessTime() == 0) {
            player.setLastBlessOfDarknessTime(System.currentTimeMillis());
        }
        Skill skill = SkillFactory.getSkill(夜光.黑暗祝福); //27100003 - 黑暗祝福 - 战斗中，如果一定时间内不受伤害，就会产生可以保护自己的暗黑球体。球体累积之后可以增加魔力，有球体的情况下受到伤害，则减少伤害值，同时减少1个球体。
        int skilllevel = player.getTotalSkillLevel(skill);
        if (skilllevel <= 0) {
            return;
        }
        MapleStatEffect effect = skill.getEffect(skilllevel);
        if (player.getStatForBuff(MapleBuffStat.黑暗祝福) == null) {
            effect.applyTo(player);
            return;
        }
        if (player.getLastBlessOfDarknessTime() + effect.getDuration() < System.currentTimeMillis()) {
            int count = player.getBuffedValue(MapleBuffStat.黑暗祝福);
            if (count < 3) {
                count++;
            }
            Map<MapleBuffStat, Integer> stat = Collections.singletonMap(MapleBuffStat.黑暗祝福, count);
            player.setBuffedValue(MapleBuffStat.黑暗祝福, count);
            player.getClient().announce(EffectPacket.showBlessOfDarkness(skill.getId()));
            player.getClient().announce(BuffPacket.giveSingleBuff(skill.getId(), 0, stat, effect, player));
            player.setLastBlessOfDarknessTime(System.currentTimeMillis());
        }
    }

    public static void handleBlackBlessLost(MapleCharacter player, int howmany) {
        Skill skill = SkillFactory.getSkill(夜光.黑暗祝福);
        if (player.getSkillLevel(skill) <= 0) {
            player.cancelEffectFromBuffStat(MapleBuffStat.黑暗祝福);
            return;
        }
        MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.黑暗祝福);
        if (effect == null) {
            return;
        }
        player.setLastBlessOfDarknessTime(System.currentTimeMillis());
        int count = player.getBuffedValue(MapleBuffStat.黑暗祝福);
        count = count - howmany;
        if (count <= 0) {
            player.cancelEffectFromBuffStat(MapleBuffStat.黑暗祝福);
        } else {
            Map<MapleBuffStat, Integer> stat = Collections.singletonMap(MapleBuffStat.黑暗祝福, count);
            player.setBuffedValue(MapleBuffStat.黑暗祝福, count);
            player.getClient().announce(EffectPacket.showBlessOfDarkness(skill.getId()));
            player.getClient().announce(BuffPacket.giveSingleBuff(skill.getId(), 0, stat, effect, player));
        }
    }

    /*
     * 夜光黑暗高潮处理
     */
    public static void handleDarkCrescendo(MapleCharacter player) {
        MapleStatEffect dkeffect = player.getStatForBuff(MapleBuffStat.黑暗高潮);
        if (dkeffect != null && dkeffect.getSourceid() == 夜光.黑暗高潮) { //27121005 - 黑暗高潮 - 在一定时间内，攻击技能每命中一次敌人，都会有一定概率提升攻击力。
            int orbcount = player.getBuffedValue(MapleBuffStat.黑暗高潮);
            Skill skill = SkillFactory.getSkill(夜光.黑暗高潮);
            if (player.getSkillLevel(skill) > 0) {
                MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(skill));
                if (orbcount < effect.getX() && effect.makeChanceResult()) {
                    int neworbcount = orbcount + 1;
                    Map<MapleBuffStat, Integer> stat = Collections.singletonMap(MapleBuffStat.黑暗高潮, neworbcount);
                    player.setBuffedValue(MapleBuffStat.黑暗高潮, neworbcount);
                    int duration = effect.getDuration();
                    duration += (int) ((player.getBuffedStartTime(MapleBuffStat.黑暗高潮) - System.currentTimeMillis()));
                    player.getClient().announce(BuffPacket.giveSingleBuff(skill.getId(), duration, stat, effect, player));
                }
            }
        }
    }

    public static void applyCriticalGrowth(MapleCharacter player) {
        final int skillid = (player.getTotalSkillLevel(侠盗.名流爆击) > 0) ? 侠盗.名流爆击 : 侠盗.暴击蓄能;
        final int totalSkillLevel = player.getTotalSkillLevel(skillid);
        if (player.getBuffedIntValue(MapleBuffStat.暴击蓄能) >= 96 || !player.getClient().isLoggedIn() || totalSkillLevel == 0) {
            return;
        }
        Optional.ofNullable(SkillFactory.getSkill(skillid)).ifPresent(skill -> {
            MapleStatEffect effect = skill.getEffect(totalSkillLevel);
            if (player.isAlive() && player.getClient().isLoggedIn() && player.getClient().getPlayer() != null) {
                effect.applyTo(player, true);
            }
        });
    }

    /*
     * 获取当前斗气的点数
     */
    public static int getOrbCount(MapleCharacter player) {
        if (player.getBuffedValue(MapleBuffStat.斗气集中) == null) {
            return 0;
        }
        return player.getBuffedValue(MapleBuffStat.斗气集中);
    }

    public static int getDarkLight(MapleCharacter player) {
        return player.getSpecialStat().getDarkLight();
    }

    /*
     * 狂龙战士变形值处理
     */
    public static boolean canMorphLost(MapleCharacter player, long now) {
        return player.getJob() >= 6100 && player.getJob() <= 6112 && player.getSpecialStat().getLastMorphLostTime() > 0 && player.getSpecialStat().getMorphCount() > 0 && player.getSpecialStat().getLastMorphLostTime() + (20 * 1000) < now;
    }

    public static void morphLostTask(MapleCharacter player) {
        if (player.getJob() >= 6100 && player.getJob() <= 6112) {
            if (player.getSpecialStat().getMorphCount() > 0) {
                player.getSpecialStat().gainMorphCount(-1);
                player.getClient().announce(BuffPacket.give狂龙变形值(player.getSpecialStat().getMorphCount()));
            }
            player.getSpecialStat().prepareMorphLostTime();
        }
    }

    public static void handleMorphCharge(MapleCharacter player, int targets) {
        Skill mchskill = SkillFactory.getSkill(狂龙战士.变身);
        int skilllevel = player.getTotalSkillLevel(mchskill);
        if (skilllevel > 0) {
            MapleStatEffect mcheff = mchskill.getEffect(skilllevel);
            if (targets > 0 && mcheff != null) {
                player.getSpecialStat().prepareMorphLostTime();
                int maxCount = player.getJob() == 6100 ? mcheff.getS() : player.getJob() == 6110 ? mcheff.getU() : mcheff.getV();
                if (player.getSpecialStat().getMorphCount() < maxCount) {
                    player.getSpecialStat().gainMorphCount(targets);
                    if (player.getSpecialStat().getMorphCount() >= maxCount) {
                        player.getSpecialStat().setMorphCount(maxCount);
                    }
                    player.getClient().announce(BuffPacket.give狂龙变形值(player.getSpecialStat().getMorphCount()));
                    if (player.isAdmin()) {
                        player.getMap().broadcastMessage(player, BuffPacket.show狂龙变形值(player.getId(), player.getSpecialStat().getMorphCount()), false);
                    }
                }
            }
        }
    }

    public static void handleDeathPact(MapleCharacter player, int moboid, boolean attackBoss) {
        if (player.getBuffStatValueHolder(MapleBuffStat.死亡契约) == null) {
            return;
        }
        int[] skills_ = {唤灵斗师.死亡契约3, 唤灵斗师.死亡契约2, 唤灵斗师.死亡契约, 唤灵斗师.死亡};
        MapleStatEffect effect = null;
        for (int skillid_ : skills_) {
            if (player.getSkillLevel(skillid_) > 0) {
                effect = SkillFactory.getSkill(skillid_).getEffect(1);
                break;
            }
        }
        MapleMonster mob = player.getMap().getMonsterByOid(moboid);
        if (effect == null || mob == null) {
            return;
        }
        MapleSummon summon = player.getSummonBySkill(effect.getSourceid());
        if (summon == null) {
            return;
        }
        int maxCount = effect.getX() - (player.hasBuffSkill(唤灵斗师.战斗大师) ? 3 : 0);
        int currentCount = player.getSpecialStat().getDeathPactCount();
        if (currentCount < maxCount) {
            player.getSpecialStat().setDeathPactCount(Math.min(currentCount + (attackBoss && mob.isBoss() ? 2 : 1), maxCount));
        } else {
            if (summon.checkLastAttackTime()) {
                player.getSpecialStat().setDeathPactCount(0);
                player.getMap().broadcastMessage(SummonPacket.summonSkillLink(player.getId(), summon.getObjectId()), player.getTruePosition());
            }
        }
        Map<MapleBuffStat, Integer> localstatups = Collections.singletonMap(MapleBuffStat.死亡契约, player.getSpecialStat().getDeathPactCount());
        player.setBuffedValue(MapleBuffStat.死亡契约, player.getSpecialStat().getDeathPactCount());
        player.getClient().announce(BuffPacket.giveSingleBuff(effect.getSourceid(), 0, localstatups, effect, player));
    }

    //超能力者 心灵传动
    public static void handlerKSTelekinesis(MapleCharacter player, int oid) {
        Skill skill = SkillFactory.getSkill(超能力者.心灵传动);
        int skilllevel = player.getSkillLevel(超能力者.心灵传动);
        if (skilllevel > 0) {
            MapleStatEffect effect = skill.getEffect(skilllevel);
            if (effect != null && effect.makeChanceResult()) {
                player.getSpecialStat().gainCardStack();
                player.getMap().broadcastMessage(ForcePacket.心灵传动攻击效果(player.getId(), oid, 超能力者.心灵传动, player.getSpecialStat().getCardStack()), player.getTruePosition());
            }
        }
    }

    public static void handle防甲穿透(MapleCharacter player, int skillid) {
        int n3 = player.getTotalSkillLevel(神射手.防甲穿透);
        if (player.getJob() > 312 || player.getJob() < 310 || n3 <= 0) {
            return;
        }
        Skill skill = SkillFactory.getSkill(神射手.防甲穿透);
        MapleStatEffect effect = skill.getEffect(n3);
        if (effect.makeChanceResult()) {
            effect.applyTo(player, effect.getDuration());
        }
    }

    /*
     * 伤害减少设置处理
     */
    public static Pair<Double, Boolean> modifyDamageTaken(MapleCharacter player, double damage, MapleMapObject attacke) {
        Pair<Double, Boolean> ret = new Pair<>(damage, false);
        if (damage < 0) {
            return ret;
        }
        if (player.getStat().ignoreDAMr > 0 && Randomizer.nextInt(100) < player.getStat().ignoreDAMr_rate) { //受到攻击时，有#prop%的概率无视伤害的#ignoreDAMr%
            damage -= Math.floor((player.getStat().ignoreDAMr * damage) / 100.0f);
        }
        if (damage > 0 && player.getStat().ignoreDAM > 0 && Randomizer.nextInt(100) < player.getStat().ignoreDAM_rate) { //受到攻击时，有#prop%的概率无视#ignoreDAM的伤害
            damage -= player.getStat().ignoreDAM;
        }
        if (damage > 0 && player.getStat().ignore_mob_damage_rate > 0) {
            damage *= Math.floor((player.getStat().ignore_mob_damage_rate * damage) / 100.0f);
        }
        Integer div = player.getBuffedValue(MapleBuffStat.祝福护甲);
        Integer div2 = player.getBuffedValue(MapleBuffStat.神圣魔法盾);
        if (div2 != null) {
            if (div2 <= 0) {
                player.cancelEffectFromBuffStat(MapleBuffStat.神圣魔法盾);
            } else {
                player.setBuffedValue(MapleBuffStat.神圣魔法盾, div2 - 1);
                damage = 0;
            }
        } else if (div != null) {
            if (div <= 0) {
                player.cancelEffectFromBuffStat(MapleBuffStat.祝福护甲);
            } else {
                player.setBuffedValue(MapleBuffStat.祝福护甲, div - 1);
                damage = 0;
            }
        }
        //好像这个BUFF吸收伤害20%
        if (player.getBuffedValue(MapleBuffStat.寒冰灵气) != null) {
            damage -= damage * (20 / 100.0);
        }
        List<Integer> attack = attacke instanceof MapleMonster || attacke == null ? null : (new ArrayList<>());
        if (damage > 0) {
            if (player.getJob() == 122 && !player.skillisCooling(圣骑士.祝福护甲)) { //祝福护甲 - 受到攻击时有一定几率生成个人保护膜，最多吸收5次伤害，提高角色的物理攻击力。保护膜最多维持60秒时间，一次发动后，在一定时间内无法再生成。
                Skill divine = SkillFactory.getSkill(圣骑士.祝福护甲);
                if (player.getTotalSkillLevel(divine) > 0) {
                    MapleStatEffect divineShield = divine.getEffect(player.getTotalSkillLevel(divine));
                    if (divineShield.makeChanceResult()) {
                        divineShield.applyTo(player);
                        player.getClient().announce(MaplePacketCreator.skillCooldown(圣骑士.祝福护甲, divineShield.getCooldown(player)));
                        player.addCooldown(圣骑士.祝福护甲, System.currentTimeMillis(), divineShield.getCooldown(player) * 1000);
                    }
                }
            } else if (player.getJob() == 2005 || player.getJob() == 2500 || player.getJob() == 2510 || player.getJob() == 2511 || player.getJob() == 2512) {
                Skill skill = SkillFactory.getSkill(隐月.精灵凝聚第1招);
                if (player.getTotalSkillLevel(skill) > 0) {
                    MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(skill));
                    //System.err.println("隐月 - 当前伤害: " + damage + " 技能减少: " + effect.getDamAbsorbShieldR() + " 百分比: " + (effect.getDamAbsorbShieldR() / 100.0));
                    damage -= damage * (effect.getDamAbsorbShieldR() / 100.0);
                    //System.err.println("隐月 - 最终伤害: " + damage);
                }
            } else if (player.getJob() == 2112) {
                Skill achilles = SkillFactory.getSkill(战神.防守策略);
                if (player.getTotalSkillLevel(achilles) > 0) {
                    MapleStatEffect multiplier = achilles.getEffect(player.getTotalSkillLevel(achilles));
                    damage = ((multiplier.getX() / 1000.0) * damage);
                }
            } else if (player.getJob() == 111 || player.getJob() == 112) {
                handleOrbgain(player, true);
            } else if (player.getJob() == 321 || player.getJob() == 322) {
                MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.伤害置换);
                if (effect != null && player.getBuffedValue(MapleBuffStat.伤害置换) != null) {
                    int buffHp = player.getBuffedValue(MapleBuffStat.伤害置换);
                    if (buffHp > 0) {
                        int xishou = (int) (damage * effect.makeRate(effect.getX())); //吸收的伤害
                        int maxxishou = (int) (player.getStat().getCurrentMaxHp() * effect.makeRate(effect.getZ())); //最大
                        if (xishou > maxxishou) {
                            xishou = maxxishou;
                        }
                        damage -= xishou;
                        buffHp -= xishou;
                    }
                    if (buffHp > 0) {
                        player.setBuffedValue(MapleBuffStat.伤害置换, buffHp);
                    } else {
                        player.cancelEffectFromBuffStat(MapleBuffStat.伤害置换);
                    }
                }
            } else if (player.getJob() == 2710 || player.getJob() == 2711 || player.getJob() == 2712) {
                player.setLastBlessOfDarknessTime(System.currentTimeMillis());
                Skill skill = SkillFactory.getSkill(夜光.黑暗祝福);
                if (player.getTotalSkillLevel(skill) > 0 && player.getBuffedValue(MapleBuffStat.黑暗祝福) != null) {
                    MapleStatEffect effect = skill.getEffect(player.getTotalSkillLevel(skill));
                    handleBlackBlessLost(player, 1);
                    damage = ((effect.getX() / 100.0) * damage);
                }
            } else if (player.getJob() == 3112) {
                Skill divine = SkillFactory.getSkill(恶魔猎手.皮肤硬化);
                if (player.getTotalSkillLevel(divine) > 0) {
                    MapleStatEffect eff = divine.getEffect(player.getTotalSkillLevel(divine));
                    damage = ((eff.getX() / 1000.0) * damage);
                }
            } else if (player.getJob() == 5112) {
                Skill divine = SkillFactory.getSkill(米哈尔.进阶灵魂盾);
                if (player.getTotalSkillLevel(divine) > 0) {
                    MapleStatEffect eff = divine.getEffect(player.getTotalSkillLevel(divine));
                    damage = ((eff.getX() / 1000.0) * damage);
                }
            } else if (player.getJob() == 3611 || player.getJob() == 3612) {
                MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.影分身);
                if (effect != null && effect.getSourceid() == 尖兵.全息投影) {
                    int 分身血量 = player.getBuffedValue(MapleBuffStat.影分身);
                    分身血量 -= damage;
                    if (分身血量 > 0) {
                        player.setBuffedValue(MapleBuffStat.影分身, 分身血量);
                    } else {
                        player.dispelSkill(尖兵.全息投影);
                    }
                }
            } else if ((player.getJob() == 512 || player.getJob() == 522 || player.getJob() == 582 || player.getJob() == 592 || player.getJob() == 572) && player.getBuffedValue(MapleBuffStat.IndieDamR) == null) {
                Skill divine = SkillFactory.getSkill(player.getJob() == 512 ? 冲锋队长.反制攻击 : 冲锋队长.反制攻击);
                int skilllevel = player.getTotalSkillLevel(divine);
                if (skilllevel > 0 && !player.skillisCooling(divine.getId())) {
                    MapleStatEffect divineShield = divine.getEffect(skilllevel);
                    if (divineShield.makeChanceResult()) {
                        divineShield.applyTo(player);
                        player.getClient().announce(EffectPacket.showBuffeffect(player, divine.getId(), EffectOpcode.UserEffect_SkillAffected.getValue(), 0, skilllevel));
                        player.getMap().broadcastMessage(EffectPacket.showOwnBuffEffect(divine.getId(), EffectOpcode.UserEffect_SkillAffected.getValue(), 0, skilllevel));
                        player.getClient().announce(MaplePacketCreator.skillCooldown(divine.getId(), divineShield.getX()));
                        player.addCooldown(divine.getId(), System.currentTimeMillis(), divineShield.getX() * 1000);
                    }
                }
            } else if (player.getJob() == 132 && attacke != null) {
                Skill divine = SkillFactory.getSkill(黑骑士.灵魂复仇);
                if (player.getTotalSkillLevel(divine) > 0 && !player.skillisCooling(divine.getId()) && player.getBuffSource(MapleBuffStat.灵魂助力) == 黑骑士.灵魂助力) {
                    MapleStatEffect divineShield = divine.getEffect(player.getTotalSkillLevel(divine));
                    if (divineShield.makeChanceResult()) {
                        player.getClient().announce(MaplePacketCreator.skillCooldown(divine.getId(), divineShield.getCooldown(player)));
                        player.addCooldown(divine.getId(), System.currentTimeMillis(), divineShield.getCooldown(player) * 1000);
                        if (attacke instanceof MapleMonster) {
                            MapleMonster attacker = (MapleMonster) attacke;
                            int theDmg = (int) (divineShield.getDamage() * player.getStat().getCurrentMaxBaseDamage() / 100.0);
                            attacker.damage(player, theDmg, true);
                            player.getMap().broadcastMessage(MobPacket.damageMonster(attacker.getObjectId(), theDmg));
                        } else {
                            MapleCharacter attacker = (MapleCharacter) attacke;
                            attacker.addHP(-divineShield.getDamage());
                            attack.add(divineShield.getDamage());
                        }
                    }
                }
            }
            if (attacke != null) {
                int damr = (Randomizer.nextInt(100) < player.getStat().DAMreflect_rate ? player.getStat().DAMreflect : 0) + (player.getBuffedValue(MapleBuffStat.伤害反击) != null ? player.getBuffedValue(MapleBuffStat.伤害反击) : 0);
                if (damr > 0) {
                    long bouncedamage = (long) (damage * damr / 100);
                    if (attacke instanceof MapleMonster) {
                        MapleMonster attacker = (MapleMonster) attacke;
                        bouncedamage = Math.min(bouncedamage, attacker.getMobMaxHp() / 10);
                        attacker.damage(player, bouncedamage, true);
                        player.getMap().broadcastMessage(player, MobPacket.damageMonster(attacker.getObjectId(), bouncedamage), player.getTruePosition());
                        if (player.getBuffSource(MapleBuffStat.伤害反击) == 恶魔猎手.黑暗复仇) {
                            MapleStatEffect eff = player.getStatForBuff(MapleBuffStat.伤害反击);
                            attacker.applyStatus(player, new MonsterStatusEffect(MonsterStatus.Stun, 1, eff.getSourceid(), null, false, 0), false, 5000, true, eff); //只有5秒
                        }
                    } else {
                        MapleCharacter attacker = (MapleCharacter) attacke;
                        bouncedamage = Math.min(bouncedamage, attacker.getStat().getCurrentMaxHp() / 10);
                        attacker.addHP(-((int) bouncedamage));
                        //log.info("减少Hp: " + ((int) bouncedamage));
                        attack.add((int) bouncedamage);
                        if (player.getBuffSource(MapleBuffStat.伤害反击) == 恶魔猎手.黑暗复仇) {
                            attacker.disease(MapleDisease.昏迷.getDisease(), 1);
                        }
                    }
                    ret.right = true;
                }
                if ((player.getJob() == 411 || player.getJob() == 412 || player.getJob() == 421 || player.getJob() == 422 || player.getJob() == 1411 || player.getJob() == 1412) && player.getBuffedValue(MapleBuffStat.IndieSummoned) != null) {
                    List<MapleSummon> ss = player.getSummonsReadLock();
                    try {
                        for (MapleSummon sum : ss) {
                            if (sum.getTruePosition().distanceSq(player.getTruePosition()) < 400000.0 && sum.is黑暗杂耍()) {
                                if (attacke instanceof MapleMonster) {
                                    List<Pair<Long, Boolean>> allDamageNumbers = new ArrayList<>();
                                    List<AttackPair> allDamage = new ArrayList<>();
                                    MapleMonster attacker = (MapleMonster) attacke;
                                    long theDmg = (long) (SkillFactory.getSkill(sum.getSkillId()).getEffect(sum.getSkillLevel()).getX() * damage / 100.0);
                                    allDamageNumbers.add(new Pair<>(theDmg, false));
                                    allDamage.add(new AttackPair(attacker.getObjectId(), allDamageNumbers));
                                    player.getMap().broadcastMessage(SummonPacket.summonAttack(sum, (byte) 0x84, (byte) 0x11, allDamage, player.getLevel(), true));
                                    attacker.damage(player, theDmg, true);
                                    player.checkMonsterAggro(attacker);
                                    if (!attacker.isAlive()) {
                                        player.getClient().announce(MobPacket.killMonster(attacker.getObjectId(), 1));
                                    }
                                } else {
                                    MapleCharacter chr = (MapleCharacter) attacke;
                                    int dmg = SkillFactory.getSkill(sum.getSkillId()).getEffect(sum.getSkillLevel()).getX();
                                    chr.addHP(-dmg);
                                    attack.add(dmg);
                                }
                            }
                        }
                    } finally {
                        player.unlockSummonsReadLock();
                    }
                }
            }
        } else if (damage == 0) {
            if ((player.getJob() == 433 || player.getJob() == 434) && attacke != null) {
                handleDivineShield(player, false);
            }
        }
        if ((player.getJob() == 3611 || player.getJob() == 3612)) {
            if (player.getBuffStatValueHolder(MapleBuffStat.宙斯盾系统) != null && attacke != null) {
                handleAegisSystem(player, attacke.getObjectId());
            }
        }
        ret.left = damage;
        return ret;
    }

    public static void handleDivineShield(MapleCharacter player, boolean succ) {
        Skill divine = SkillFactory.getSkill(双刀.影子闪避);
        if (player.getTotalSkillLevel(divine) > 0) {
            MapleStatEffect divineShield = divine.getEffect(player.getTotalSkillLevel(divine));
            int prop = succ ? 100 : divineShield.getER();
            if (Randomizer.nextInt(100) < prop && !player.isBuffFrom(MapleBuffStat.增加物理攻击力, divine)) {
                divineShield.applyTo(player, true);
                player.getCheatTracker().resetTakeDamage();
                player.getClient().announce(MaplePacketCreator.sendCritAttack());
            }
        }
    }

    /**
     * 怪物死亡前的处理
     */
    public static void beforeKillMonster(MapleCharacter player, int moboid, int skillid) {
        /* 角色是恶魔猎手时吸收精气 */
        if (JobConstants.is恶魔猎手(player.getJob()) && skillid != 新手.升级特效) {
            handleForceGain(player, moboid, 恶魔猎手.死亡诅咒);
        } else if (JobConstants.is唤灵斗师(player.getJob())) {
            handleDeathPact(player, moboid, false);
        }
    }

    public static void handleFinalAttack(MapleCharacter player, int moboid, int skillid, int tYple) {
        List<Integer> finalAttackSkills = SkillFactory.getFinalAttackSkills();
        if (!finalAttackSkills.contains(skillid)) {
            return;
        }
        for (Integer integer : finalAttackSkills) {
            Skill skill = SkillFactory.getSkill(integer);
            int job = integer / 10000;
            int skilllevel = player.getSkillLevel(SkillConstants.getLinkedAttackSkill(integer));
            if (skill == null) {
                continue;
            }
            MapleStatEffect effect = skill.getEffect(skilllevel);
            if (job >= player.getJob() - 2 && job <= player.getJob() && skilllevel > 0 && effect != null && effect.makeChanceResult() && (ItemConstants.isMainWeapon(player, job, 0) || (player.skillisCooling(2221007) && integer == 2220014) || (player.skillisCooling(2121007) && integer == 2120013)) && (integer != 4341054 || player.getBuffedIntValue(MapleBuffStat.隐形剑) > 0)) {
                Item weapon_ = player.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -11);
                MapleWeaponType type = weapon_ == null ? MapleWeaponType.没有武器 : ItemConstants.getWeaponType(weapon_.getItemId());
                player.getClient().announce(MaplePacketCreator.ExtraAttack(skillid, skill.getId(), type.getWeaponType(), tYple, moboid));
                break;
            }
        }
    }

    /*
     * 精灵的祝福
     */
    public static boolean getCygnusBless(MapleCharacter player) {
        int jobid = player.getJob();
        return player.getSkillLevel(12) > 0 && (jobid >= 0 && jobid < 1000) //冒险家
                || player.getSkillLevel(10000012) > 0 && (jobid >= 1000 && jobid < 2000) //骑士团
                || player.getSkillLevel(20000012) > 0 && (jobid == 2000 || jobid >= 2100 && jobid <= 2112) //战神
                || player.getSkillLevel(20010012) > 0 && (jobid == 2001 || JobConstants.is龙神(jobid)) //龙神
                || player.getSkillLevel(20020012) > 0 && (jobid == 2002 || jobid >= 2300 && jobid <= 2312) //双弩精灵
                || player.getSkillLevel(20030012) > 0 && (jobid == 2003 || jobid >= 2400 && jobid <= 2412) //幻影神偷
                || player.getSkillLevel(20040012) > 0 && (jobid == 2004 || jobid >= 2700 && jobid <= 2712) //夜光法师
                || player.getSkillLevel(30000012) > 0 && (jobid == 3000 || jobid >= 3200 && jobid <= 3512) //反抗职业
                || player.getSkillLevel(30010012) > 0 && (JobConstants.is恶魔(jobid)) //恶魔职业
                || player.getSkillLevel(30020012) > 0 && (jobid == 3002 || jobid >= 3600 && jobid <= 3612) //尖兵
                || player.getSkillLevel(50000012) > 0 && (jobid == 5000 || jobid >= 5100 && jobid <= 5112) //米哈尔
                || player.getSkillLevel(60000012) > 0 && (jobid == 6000 || jobid >= 6100 && jobid <= 6112) //狂龙战士
                || player.getSkillLevel(60010012) > 0 && (jobid == 6001 || jobid >= 6500 && jobid <= 6512) //爆莉萌天使
                || player.getSkillLevel(100000012) > 0 && (jobid == 10000 || jobid >= 10100 && jobid <= 10112) //神之子
                || player.getSkillLevel(110000012) > 0 && (jobid == 11000 || jobid >= 11200 && jobid <= 11212) //林之灵
                ;
    }

    public static byte get精灵祝福(MapleCharacter player) {
        int jobid = player.getJob();
        if (player.getSkillLevel(20021110) > 0 && (jobid == 2002 || jobid >= 2300 && jobid <= 2312) || player.getSkillLevel(80001040) > 0) {
            return 10;
        }
        return 0;
    }

    /*
     * 恶魔猎手吸收精气
     */
    public static void handleForceGain(MapleCharacter player, int oid, int skillid) {
        handleForceGain(player, oid, skillid, 0);
    }

    public static void handleForceGain(MapleCharacter player, int moboid, int skillid, int extraForce) {
        if (!SkillConstants.isForceIncrease(skillid) && extraForce <= 0) {
            return;
        }
        int n13 = skillid == 31121052 ? 15 : Randomizer.nextInt(5) + 1;
        MapleStatEffect effect = player.getSkillEffect(skillid);
        MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, moboid);
        player.send_other(forceAtom.getPacket(), true);
        MapleStatEffect effect_ex = player.getSkillEffect(31110009);
        if (effect_ex != null && effect_ex.makeChanceResult(player)) {
            forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, moboid);
            player.send_other(forceAtom.getPacket(), true);
        }
        player.addHPMP(0, n13, false);
        if (n13 >= 50) {
            player.reduceCooldown(31121054, 3000);
        }
    }

    public static void handleCarteGain(MapleCharacter player, int moid, boolean is5th) {
        if (is5th) {
            Skill skill = SkillFactory.getSkill(幻影.小丑_1);
            if (skill != null && player.getSkillLevel(幻影.王牌) > 0) {
                MapleStatEffect effect = skill.getEffect(player.getSkillLevel(幻影.王牌));
                if (effect != null) {
                    MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, 0);
                    player.getSpecialStat().gainCardStack();
                    player.send(MaplePacketCreator.updateCardStack(player.getSpecialStat().getCardStack()));
                    player.send_other(forceAtom.getPacket(), true);
                }
            }
        } else {
            int[] arrn2 = new int[]{幻影.黑色秘卡, 幻影.卡片雪舞};
            final int maxCarte = (player.getSkillLevel(幻影.卡牌审判_高级) > 0) ? 40 : 20;
            for (int skillid : arrn2) {
                Skill skill = SkillFactory.getSkill(skillid);
                if (skill != null && player.getSkillLevel(skill) > 0) {
                    MapleStatEffect effect = skill.getEffect(player.getSkillLevel(skill));
                    if (effect.makeChanceResult() && Randomizer.nextInt(100) <= player.getStat().passive_sharpeye_rate()) {
                        MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, 0);
                        player.send(forceAtom.getPacket());
                        if (player.getCardStack() < maxCarte) {
                            player.getSpecialStat().gainCardStack();
                        }
                    }
                    player.send(MaplePacketCreator.updateCardStack(player.getSpecialStat().getCardStack()));
                }
            }
        }
    }

    /*
     * 处理尖兵 精准火箭
     */
    public static void handleCardStack(MapleCharacter player, int skillId) {
        if (skillId == 0 || skillId == 尖兵.精准火箭 || skillId == 尖兵.宙斯盾系统_攻击) {
            return;
        }
        Skill skill = SkillFactory.getSkill(尖兵.精准火箭);
        if (player.getSkillLevel(skill) > 0) {
            MapleStatEffect effect = skill.getEffect(player.getSkillLevel(skill));
            // 冷却时间3秒
            if (System.currentTimeMillis() - player.getLastForceTime() < 3000) {
                return;
            }
            if (effect != null) {
                List<MapleMapObject> mobs = player.getMap().getMonstersInRange(player.getPosition(), 38400);
                List<Integer> mobids = new ArrayList<>();
                if (mobs.isEmpty()) {
                    return;
                }
                for (int i = 0; i < effect.getMobCount(); i++) {
                    mobids.add(mobs.get(Randomizer.nextInt(mobs.size())).getObjectId());
                }
                MapleForce mapleForce = new MapleForce(player.getId(), 尖兵.精准火箭, 0, MapleForceType.尖兵火箭, (byte) 1, mobids, (byte) 0, effect.getBulletCount(), player.getMap());
                player.getClient().announce(mapleForce.writePacket());
            }
            player.setLastForceTime(System.currentTimeMillis());
        }
    }

    public static void handleAegisSystem(MapleCharacter player, int toMobOid) {
        Skill skill = SkillFactory.getSkill(尖兵.宙斯盾系统);
        if (player.getSkillLevel(skill) > 0) {
            MapleStatEffect effect = skill.getEffect(player.getSkillLevel(skill));
            if (effect != null) {
                // 冷却时间3秒
                if (System.currentTimeMillis() - player.getLastAegisTime() < effect.getY()) {
                    return;
                }
                if (effect.getProp() > Randomizer.nextInt(100)) {
                    MapleForce mapleForce = new MapleForce(player.getId(), 尖兵.宙斯盾系统_攻击, 0, MapleForceType.宙斯盾系统, (byte) 1, Collections.singletonList(toMobOid), (byte) 0, effect.getX(), player.getMap());
                    player.getClient().announce(mapleForce.writePacket());
                }
                player.setLastAegisTime(System.currentTimeMillis());
            }
        }
    }

    /*
     * 处理刺客标记攻击怪物效果
     */
    public static void handleAssassinStack(MapleCharacter player, MapleMonster mob) {
        int[] skillid = {隐士.刺客标记, 隐士.隐士标记};
        for (int i : skillid) {
            MapleStatEffect effect = player.getSkillEffect(i);
            if (effect == null) {
                continue;
            }
            if (effect.makeChanceResult() && mob != null) {
                List<MapleMapObject> arrayList = player.getMap().getMapObjectsInRange(mob.getPosition(), 250000.0, Collections.singletonList(MapleMapObjectType.MONSTER));
                List<Integer> tomobids = new ArrayList<>();
                for (MapleMapObject mobj : arrayList) {
                    tomobids.add(mobj.getObjectId());
                }
                MapleForceAtom forceAtom = MapleForceAtomFactory.INSTANCE.createForceAtom(player, effect, mob.getObjectId(), tomobids, mob.getPosition());
                player.getMap().broadcastMessage(player, forceAtom.getPacket(), true);
                mob.removeEffect(player.getId(), effect.getSourceid());
            }
        }
    }

    public static void apply刺客标记(MapleCharacter player, MapleMonster monster) {
        MapleStatEffect effect;
        Skill aq2 = SkillFactory.getSkill(隐士.刺客标记);
        Skill aq3 = SkillFactory.getSkill(隐士.隐士标记);
        if (player.getTotalSkillLevel(aq3) > 0) {
            effect = aq3.getEffect(player.getTotalSkillLevel(aq3));
        } else if (player.getTotalSkillLevel(aq2) > 0) {
            effect = aq2.getEffect(player.getTotalSkillLevel(aq2));
        } else {
            return;
        }
        if (effect.makeChanceResult() && player.getStatForBuff(MapleBuffStat.刺客标记) != null) {
            monster.setmark(true);
            monster.applyStatus(new MonsterStatusEffect(MonsterStatus.Poison, 1, effect.getSourceid(), null, false));
        }
    }

    /*
     * 金钱炸弹处理
     */
    public static void handleMesoExplosion(MapleCharacter player) {
        Skill skill = SkillFactory.getSkill(侠盗.金钱炸弹);
        int skillLevel = player.getTotalSkillLevel(skill);
        if (skillLevel <= 0) {
            return;
        }
        MapleStatEffect effect = skill.getEffect(skillLevel);
        MapleStatEffect effect_fadong = SkillFactory.getSkill(侠盗.金钱炸弹_攻击).getEffect(skillLevel);
        if (effect != null && effect_fadong != null) {
            //处理攻击怪物的ID
            int mobCount = effect.getMobCount(); //攻击的怪物数量
            Rectangle bounds = MapleStatEffectFactory.calculateBoundingBox(effect_fadong, player.getTruePosition(), player.isFacingLeft());
            List<MapleMapObject> affected = player.getMap().getMapObjectsInRect(bounds, Collections.singletonList(MapleMapObjectType.MONSTER));
            List<Integer> moboids = new ArrayList<>();
            for (MapleMapObject mo : affected) {
                if (moboids.size() < mobCount) {
                    moboids.add(mo.getObjectId());
                }
            }
            if (moboids.isEmpty()) {
                return;
            }
            //处理使用金币的数量
            int mesoCount = effect.getBulletCount() + (player.getTotalSkillLevel(侠盗.金钱炸弹_增强) > 0 ? 5 : 0); //能够使用的金币数量
            affected = player.getMap().getMapObjectsInRect(bounds, Collections.singletonList(MapleMapObjectType.ITEM));
            List<Point> posFroms = new ArrayList<>();
            for (MapleMapObject mo : affected) {
                if (posFroms.size() < mesoCount) {
                    MapleMapItem mapitem = (MapleMapItem) mo;
                    mapitem.getLock().lock();
                    try {
                        if (mapitem.getMeso() > 0 && !mapitem.isPickedUp() && mapitem.getOwner() == player.getId()) {
                            Point droppos = new Point(mapitem.getTruePosition());
                            posFroms.add(droppos);
                            //移除以前的金币
                            mapitem.setPickedUp(true);
                            player.getMap().broadcastMessage(InventoryPacket.removeItemFromMap(mapitem.getObjectId(), 0, 0), mapitem.getPosition());
                            player.getMap().removeMapObject(mapitem);
                        }
                    } finally {
                        mapitem.getLock().unlock();
                    }
                }
            }
            //发送封包
            player.getSpecialStat().gainForceCounter();
            player.getClient().announce(ForcePacket.金钱炸弹效果(player.getId(), effect_fadong.getSourceid(), player.getSpecialStat().getForceCounter(), moboids, posFroms));
            player.getSpecialStat().gainForceCounter(posFroms.size());
        }
    }

    public static void handle狂风肆虐(MapleCharacter player, int skillid) {
        MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.狂风肆虐);
        if (effect != null) {
            if (skillid == effect.getSourceid()) {
                return;
            }
            int prop = effect.getProp() + (player.getSkillLevel(风灵使者.狂风肆虐_增强) > 0 ? 10 : 0);
            int subprop = effect.getSubProp() + (player.getSkillLevel(风灵使者.狂风肆虐_增强) > 0 ? 10 : 0);
            //是否触发下面的效果
            if (Randomizer.isSuccess(prop)) {
                int mobCount = effect.getX() * (player.getSkillLevel(风灵使者.狂风肆虐_二次机会) > 0 ? 2 : 1);
                int count = Randomizer.rand(1, mobCount);
                if (count > mobCount / 2) {
                    count = Randomizer.rand(1, mobCount);
                }
                MapleForce mapleForce = new MapleForce(player.getId(), effect.getSourceid(), 0, MapleForceType.狂风肆虐, (byte) 1, new ArrayList<>(), (byte) -1, 1, player.getMap());
                Rectangle bounds = MapleStatEffectFactory.calculateBoundingBox(effect, player.getTruePosition(), player.isFacingLeft());
                List<MapleMapObject> affected = player.getMap().getMapObjectsInRect(bounds, Collections.singletonList(MapleMapObjectType.MONSTER));
                if (affected.isEmpty()) {
                    return;
                }
                for (int i = 0; i < count; i++) {
                    mapleForce.addForce(affected.get(Randomizer.nextInt(affected.size())).getObjectId(), (byte) (Randomizer.nextInt(100) <= subprop ? 2 : 1), player.getMap());
                }
                player.getClient().announce(mapleForce.writePacket());
            }
        }
    }

    public static void handle暴风灭世(MapleCharacter player, int oid) {
        MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.暴风灭世);
        if (effect != null) {
            MapleMonster monster = player.getMap().getMonsterByOid(oid);
            if (effect.makeChanceResult() && monster != null && !monster.isFake()) {
                MapleForce force = new MapleForce(player.getId(), 风灵使者.暴风灭世, 0, MapleForceType.暴风灭世, (byte) 1, Collections.singletonList(oid), (byte) 1, effect.getBulletCount(), player.getMap(), player.isFacingLeft());
                player.send_other(force.writePacket(), true);
            }
        }
    }

    public static void handle火焰传动(MapleCharacter player) {
        //初始化坐标信息
        if (player.getFlameMapId() != player.getMapId() || player.getFlamePoint() == null) {
            player.setFlameMapId(player.getMapId());
            player.setFlamePoint(new Point(player.getTruePosition()));
        }
        //检测坐标信息
        if (!player.getFlamePoint().equals(player.getTruePosition())) {
            player.getClient().announce(MaplePacketCreator.instantMapWarp(player.getId(), player.getFlamePoint()));
            player.checkFollow();
            player.getMap().movePlayer(player, player.getFlamePoint());
            player.setFlamePoint(null);
        }
    }

    public static int get超越数值(MapleCharacter player) {
        if (player.getBuffedValue(MapleBuffStat.恶魔超越) == null) {
            return 0;
        }
        return player.getBuffedValue(MapleBuffStat.恶魔超越);
    }

    public static void handle超越状态(MapleCharacter player, int skillId) {
        if (!SkillConstants.is超越攻击(skillId)) {
            return;
        }
        //处理超越攻击
        int linkSkillId = SkillConstants.getLinkedAttackSkill(skillId);
        Skill skill = SkillFactory.getSkill(linkSkillId);
        int skilllevel = player.getSkillLevel(skill);
        if (skilllevel <= 0) {
            return;
        }
        skill.getEffect(skilllevel).applyTranscendBuff(player);
        //处理超越状态
        skill = SkillFactory.getSkill(恶魔复仇者.超越);
        skilllevel = player.getSkillLevel(skill);
        if (skilllevel <= 0) {
            return;
        }
        MapleStatEffect effect = skill.getEffect(skilllevel);
        MapleBuffStat buffStat = MapleBuffStat.恶魔超越;
        if (player.getBuffedValue(buffStat) == null) {
            effect.applyTo(player); //注册第1次的BUFF效果
            return;
        }
        int oldCombos = player.getBuffedIntValue(buffStat);
        if (oldCombos < 20) {
            int newCombos = oldCombos;
            newCombos += 1;
            if (newCombos >= 20) {
                newCombos = 20;
            }
            if (newCombos != oldCombos) {
                player.setBuffedValue(buffStat, newCombos);
            }
            Map<MapleBuffStat, Integer> stat = Collections.singletonMap(buffStat, newCombos);
            player.getClient().announce(BuffPacket.giveSingleBuff(effect.getSourceid(), effect.getDuration(), stat, effect, player));
        }
    }

    /*
     * 处理夜行者影子蝙蝠效果
     */
    public static void handle影子蝙蝠(MapleCharacter player, int oid) {
        //处理召唤蝙蝠
        Skill BuffSkill = SkillFactory.getSkill(夜行者.影子蝙蝠);
        Skill skill_1 = SkillFactory.getSkill(夜行者.影子蝙蝠_召唤兽);
        Skill skill_2 = SkillFactory.getSkill(夜行者.蝙蝠掌控);
        Skill skill_3 = SkillFactory.getSkill(夜行者.蝙蝠掌控Ⅱ);
        Skill skill_4 = SkillFactory.getSkill(夜行者.蝙蝠掌控Ⅲ);
        int skillLevel_1 = player.getSkillLevel(BuffSkill);
        int skillLevel_2 = player.getSkillLevel(skill_2);
        int skillLevel_3 = player.getSkillLevel(skill_3);
        int skillLevel_4 = player.getSkillLevel(skill_4);
        if (skillLevel_1 < 0) {
            return;
        }
        MapleStatEffect effect = skill_1.getEffect(skillLevel_1);
        int attackCount = effect.getZ(); //攻击多少次可以召唤蝙蝠
        player.setAttackHit(player.getAttackHit() + 1);
        if (player.getAttackHit() < attackCount) {
            return; //必须命中3次才召唤怪物
        }
        int maxS = effect.getY();
        if (skillLevel_2 > 0) {
            maxS = maxS + 1;
        }
        if (skillLevel_3 > 0) {
            maxS = maxS + 1;
        }
        if (skillLevel_4 > 0) {
            maxS = maxS + 1;
        }
        int nowSummon = player.getSummonsSize(); //当前已经召唤的数量
        if (nowSummon < maxS) {
            effect.applyTo(player); //处理召唤兽
        }
        player.setAttackHit(0);
    }

    /*
     * 侠盗本能击杀点数
     */
    public static void handleKillSpreeGain(MapleCharacter player) {
        Skill skill = SkillFactory.getSkill(侠盗.侠盗本能);
        int skillLevel = player.getSkillLevel(skill);
        int killSpree = player.getBuffedIntValue(MapleBuffStat.击杀点数);
        if (skillLevel <= 0 || killSpree >= 5) {
            return;
        }
        if (Randomizer.nextInt(100) <= 20) {
            skill.getEffect(skillLevel).applyTo(player, true);
        }
    }

    /*
     * 奇袭者元素雷电被动BUFF设置
     */
    public static void handle元素雷电(MapleCharacter player, int skillId) {
        //这几个技能是不加雷电次数的
        if (skillId == 奇袭者.疾风 || skillId == 奇袭者.毁灭 || skillId == 奇袭者.台风) {
            return;
        }
        Skill skill = SkillFactory.getSkill(奇袭者.元素_闪电);
        int skillLevel = player.getSkillLevel(skill);
        if (skillLevel <= 0 || player.getBuffedValue(MapleBuffStat.元素属性) == null) {
            return;
        }
        if (Randomizer.nextInt(100) <= player.getStat().raidenPorp) {
            skill.getEffect(skillLevel).applyTo(player, true);
        }
    }

    /*
     * 圣骑士元素冲击处理
     */
    public static void handleElementalCharge(MapleCharacter player, int skillId) {
        if (player.getJob() > 122 || player.getJob() < 120 || skillId != 1201011 & skillId != 1201012 & skillId != 1211008 & skillId != 1221004) {
            return;
        }
        if (player.getLastSkill() == skillId || player.getLastSkill() == 0) {
            player.setLastSkill(skillId);
            return;
        }
        int newSkill = player.getTotalSkillLevel(1220010) > 0 ? 1220010 : 1200014;
        player.getSkillEffect(newSkill).applyTo(player, 0);
        player.setLastSkill(skillId);
    }

    /*
     * 神之子攻击BUFF
     */
    public static void handle提速时刻(MapleCharacter player) {
        Skill skill = SkillFactory.getSkill(player.isZeroSecondLook() ? 神之子.提速时刻_战斗 : 神之子.提速时刻_侦查);
        int skillLevel = 1;
        skill.getEffect(skillLevel).applyTo(player, true);
    }

    public static void handleHeartMineUnity(MapleCharacter player) {
        MapleStatEffect effect;
        Skill skill = SkillFactory.getSkill(奇袭者.心雷合一);
        if (player.getSkillLevel(奇袭者.心雷合一) > 0 && player.getBuffedIntValue(MapleBuffStat.心雷合一) > 0 && (effect = skill.getEffect(player.getSkillLevel(奇袭者.心雷合一))) != null) {
            int n2 = effect.getX();
            List<MapleMapObject> list = player.getMap().getMonstersInRange(player.getTruePosition(), 100000.0);
            ArrayList<Integer> arrayList = new ArrayList<>();
            list.forEach(y2 -> {
                        MapleMonster monster = (MapleMonster) y2;
                        if (!monster.getStats().isFriendly() && !monster.isFake() && arrayList.size() < n2) {
                            arrayList.add(y2.getObjectId());
                        }
                    }
            );
            MapleForce force = new MapleForce(player.getId(), 奇袭者.心雷合一_1, 0, MapleForceType.心雷合一, (byte) 1, arrayList, (byte) 1, 1, player.getMap());
            player.send_other(force.writePacket(), true);
        }
    }

    /**
     * 获取某个技能的最大伤害上限
     *
     * @param player
     * @param skillId
     * @return
     */
    public static long getMaxDamageOver(MapleCharacter player, int skillId) {
        long maxDamage = 10000000000L; //默认的攻击上限
        long skillMaxDamage; //技能的攻击最大上限
        long limitBreak = player.getStat().getLimitBreak(player); //武器突破极限的伤害上限
        long incMaxDamage = player.getStat().incMaxDamage; //潜能增加的伤害上限
        Skill skill = SkillFactory.getSkill(skillId);
        if (skillId != 0 && skill != null) {
            if (skillId == 新手.升级特效) {
                return maxDamage;
            }
            skillMaxDamage = skill.getMaxDamageOver();
            if ((skillId == 侠盗.暗杀 || skillId == 侠盗.暗杀_1) && player.getTotalSkillLevel(侠盗.暗杀_最大值提高) > 0) {
                skillMaxDamage = 70000000;
            } else if (skillId == 夜光.绝对死亡) {
                skillMaxDamage = maxDamage;
            } else if (skillId == 箭神.一击要害箭 && player.getTotalSkillLevel(箭神.一击要害箭_最大值提高) > 0) {
                skillMaxDamage = 500000000;
            }
            return (limitBreak > skillMaxDamage ? limitBreak : skillMaxDamage) + incMaxDamage;
        }
        return (limitBreak < maxDamage && limitBreak > 0 ? limitBreak : maxDamage) + incMaxDamage;
    }

    /*
     * 检测 林子灵技能
     */
    public static void checkBeastTamerSkill(MapleCharacter player) {
        // 11212 = 林之灵4转 这个职业默认是4转角色 如果不是返回 不进行下面的操作
        if (player.getJob() != 11212 || player.getLevel() < 10) {
            return;
        }
        Skill skil;
        Map<Integer, SkillEntry> list = new HashMap<>();
        //检测新手技能 , 林之灵.猛鹰模式, 林之灵.猫咪模式 暂时不开放后面2个模式
        int[] skillIds = {林之灵.模式解除, 林之灵.巨熊模式, 林之灵.雪豹模式, 林之灵.守护者的身手, 林之灵.守护模式变更, 林之灵.精灵集中, 林之灵.猛鹰模式, 林之灵.猫咪模式};
        for (int i : skillIds) {
            skil = SkillFactory.getSkill(i);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(i, new SkillEntry((byte) 1, (byte) 1, -1));
            }
        }
        //驯兽魔法棒练习 30级开始自动学习 技能最大等级10    10级技能增加1级
        skil = SkillFactory.getSkill(林之灵.驯兽魔法棒练习);
        if (skil != null && player.getLevel() >= 30) {
            int oldskilllevel = player.getSkillLevel(skil);
            int newskilllevel = player.getLevel() / 10 - 2;
            if (newskilllevel > skil.getMaxLevel()) {
                newskilllevel = skil.getMaxLevel();
            }
            if (newskilllevel > 0 && newskilllevel > oldskilllevel && oldskilllevel < skil.getMaxLevel()) {
                list.put(林之灵.驯兽魔法棒练习, new SkillEntry((byte) newskilllevel, (byte) skil.getMaxLevel(), -1));
            }
        }
        //冒险岛守护勇士 120级学习 技能最大等级30
        if (player.getLevel() >= 120) {
            skil = SkillFactory.getSkill(林之灵.冒险岛守护勇士);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(林之灵.冒险岛守护勇士, new SkillEntry((byte) skil.getMaxLevel(), (byte) skil.getMaxLevel(), -1));
            }
        }
        //林之灵之意志 150级学习 技能最大等级5
        if (player.getLevel() >= 150) {
            skil = SkillFactory.getSkill(林之灵.林之灵之意志);
            if (skil != null && player.getSkillLevel(skil) <= 0) {
                list.put(林之灵.林之灵之意志, new SkillEntry((byte) skil.getMaxLevel(), (byte) skil.getMaxLevel(), -1));
            }
        }
        //改变技能等级
        if (!list.isEmpty()) {
            player.changeSkillsLevel(list);
        }
    }

    /*
     * 获取林之灵当前模式投入的技能点数
     */
    public static int getBeastTamerSkillLevels(MapleCharacter player, int skillId) {
        int ret = 0;
        int mod = skillId / 10000;
        if (mod == 11200 || mod == 11210 || mod == 11211 || mod == 11212) {
            Map<Integer, SkillEntry> chrSkills = new HashMap<>(player.getSkills());
            for (Map.Entry<Integer, SkillEntry> list : chrSkills.entrySet()) {
                Skill skill = SkillFactory.getSkill(list.getKey());
                if (list.getKey() / 10000 == mod && !skill.isLinkedAttackSkill()) {
                    ret += player.getSkillLevel(list.getKey());
                }
            }
        }
        return ret;
    }

    /*
     * 林之灵之修养 这个技能的等级是任务显示
     * 59340 技能的等级任务
     * 59341 技能当前的经验
     */
    public static void gainBeastTamerSkillExp(MapleCharacter player, int amount) {
        if (player.getJob() != 11212 || player.getLevel() < 60 || amount < 0) {
            return;
        }
        Skill skil = SkillFactory.getSkill(林之灵.林之灵之修养);
        if (skil == null) {
            return;
        }
        //技能的等级任务
        MapleQuestStatus levelStat = player.getQuestNAdd(MapleQuest.getInstance(59340));
        if (levelStat.getCustomData() == null) {
            levelStat.setCustomData("1"); //默认为1级
        }
        if (levelStat.getStatus() != 1) {
            levelStat.setStatus((byte) 1);
        }
        //技能当前的经验
        MapleQuestStatus expStat = player.getQuestNAdd(MapleQuest.getInstance(59341));
        if (expStat.getCustomData() == null) {
            expStat.setCustomData("0"); //默认的经验
        }
        if (expStat.getStatus() != 1) {
            expStat.setStatus((byte) 1);
        }
        int skillLevel = Integer.parseInt(levelStat.getCustomData());
        //角色以前的技能等级 修复角色技能的等级设置
        if (player.getSkillLevel(skil) <= skillLevel) {
            Map<Integer, SkillEntry> sDate = new HashMap<>();
            sDate.put(skil.getId(), new SkillEntry((byte) skillLevel, (byte) skil.getMaxLevel(), -1));
            player.changeSkillLevel_Skip(sDate, false);
            player.updateQuest(levelStat, true);
            player.updateQuest(expStat, true);
            player.setChanged_skills(true);
            return;
        }
        int skillExp = Integer.parseInt(expStat.getCustomData());
        int needed = skil.getBonusExpInfo(skillLevel);
        int newExp = skillExp + amount;
        if (newExp >= needed) {
            if (skillLevel < skil.getMaxLevel()) {
                int newLevel = skillLevel + 1;
                if (newLevel > skil.getMaxLevel()) {
                    newLevel = skil.getMaxLevel();
                }
                Map<Integer, SkillEntry> sDate = new HashMap<>();
                sDate.put(skil.getId(), new SkillEntry((byte) newLevel, (byte) skil.getMaxLevel(), -1));
                player.changeSkillLevel_Skip(sDate, false);
                levelStat.setCustomData(String.valueOf(newLevel));
                expStat.setCustomData("0");
                player.setChanged_skills(true);
            } else { //角色技能满级后的处理
                levelStat.setCustomData("30");
                expStat.setCustomData("10000");
            }
        } else {
            expStat.setCustomData(String.valueOf(newExp));
        }
        player.updateQuest(levelStat, true);
        player.updateQuest(expStat, true);
    }

    public static void autoCelebrityCrit(MapleCharacter player) {
        final int skilllevel = player.getSkillLevel(侠盗.名流爆击);
        if (skilllevel <= 0 || player.getCelebrityCrit() != null) {
            return;
        }
        player.setCelebrityCrit(Timer.BuffTimer.getInstance().register(() -> {
                    Map<MapleBuffStat, Integer> stat = Collections.singletonMap(MapleBuffStat.暴击蓄能, skilllevel * 2);
            player.getClient().announce(BuffPacket.giveSingleBuff(侠盗.名流爆击, 0, stat, player.getSkillEffect(侠盗.名流爆击), player));
                }, 1000 * 10)
        );
    }

    public static void cannelAutoCelebrityCrit(MapleCharacter player) {
        if (player.getCelebrityCrit() != null) {
            player.getCelebrityCrit().cancel(true);
            player.setCelebrityCrit(null);
        }
    }

    public static void onAttack(MapleCharacter player, long monsterMaxHp, int monsterMaxMp, int attackid, int moboid, long totalDamage) {
        if (player.canRecoverAttack(System.currentTimeMillis())) {
            totalDamage = Math.min(0xCCCCCCC, totalDamage);
//            player.prepareRecovery();
//            if (player.getStat().hpRecoverProp > 0.0 && Randomizer.nextInt(100) <= player.getStat().hpRecoverProp) {
//                if (player.getStat().hpRecover > 0) {
//                    player.healHP(player.getStat().hpRecover);
//                }
//                if (player.getStat().hpRecover_Percent > 0) {
//                    totalDamage = totalDamage < 0 ? (long) (player.getStat().getCurrentMaxHp() / 2) : totalDamage;
//                    int n5 = (int) Math.min((double) monsterMaxHp, Math.min((double) (player.isUseHp() ? (long) player.getStat().getCurrentMaxHp() : totalDamage) * ((double) player.getStat().hpRecover_Percent / 100.0), (double) (player.getStat().getCurrentMaxHp() / 2)));
//                    if (JobConstants.is恶魔复仇者(player.getJob()) && player.getBuffedIntValue(MapleBuffStat.恶魔狂怒) > 0) {
//                        n5 = Math.min(n5, player.getStat().getCurrentMaxHp() / 100);
//                    }
//                    player.addHPMP(n5, 0, false);
//                }
//            }

            Integer value = player.getBuffedValue(MapleBuffStat.生命吸收);
            if (value != null && totalDamage > 0) {
                /*使用将给敌人造成的伤害的一部分转化为HP的增益。最多恢复角色最大HP的20%，只有在#c斗气点数在30以上#时才能使用。*/
                /*消耗斗气点数#comboConAran，在#time秒内将伤害的#x%转化为HP*/
                MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.生命吸收);
                double maxhp_per = 50;
                switch (player.getBuffSource(MapleBuffStat.生命吸收)) {
                    case 恶魔猎手.吸血鬼之触:
                        int currentdate = Integer.valueOf(DateUtil.getCurrentDate("ddHHmmss"));
                        if (value + effect.getY() > currentdate) {
                            break;
                        } else {
                            maxhp_per = effect.getW();
                            player.getBuffStatValueHolder(MapleBuffStat.生命吸收).setValue(currentdate);
                        }
                    default:
                        player.addHP(((int) Math.min(monsterMaxHp, Math.min(((int) ((double) totalDamage * (double) effect.getX() / 100.0)), ((double) player.getStat().getMaxHp() / 100.0) * maxhp_per))));
                        break;
                }
            }
            if (player.getStat().mpRecoverProp > 0 && !JobConstants.isNotMpJob(player.getJob()) && Randomizer.nextInt(100) <= player.getStat().mpRecoverProp && player.getStat().mpRecover > 0) {
                player.healMP(player.getStat().mpRecover);
            }
            if (attackid > 0) {
                MapleStatEffect effect = player.getSkillEffect(attackid);
                switch (attackid) {
                    case 14101006:
                    case 31111003:
                    case 33111006: {
                        player.addHP((int) Math.min((double) monsterMaxHp, Math.max(Math.min((double) totalDamage * ((double) effect.getX() / 100.0), (double) (player.getStat().getCurrentMaxHp() / 2)), (double) (player.getStat().getCurrentMaxHp() / 2))));
                        break;
                    }
                    case 5221015:
                    case 5721003:
                    case 22151002: {
                        player.clearLinkMid();
                        player.setLinkMid(moboid, effect.getX());
                    }
                }
            }
        }
    }

    public static void hadnleChargeBlaster(MapleCharacter player) {
        if (JobConstants.is爆破手(player.getJob())) {// && getBullet() <= 0
            Optional.ofNullable(SkillFactory.getSkill(爆破手.装填弹药)).ifPresent(skill -> {
                skill.getEffect(player.getSkillLevel(爆破手.装填弹药)).applyTo(player);
            });
        }
    }

    public static void hadnle忍耐之盾(MapleCharacter player, int n2) {
        if (JobConstants.is爆破手(player.getJob()) && player.getStatForBuff(MapleBuffStat.忍耐之盾) == null) {
            player.getSpecialStat().setHurtHP(n2);
            int skillLevel = player.getTotalSkillLevel(爆破手.忍耐之盾);
            if (skillLevel > 0) {
                MapleStatEffect effect = SkillFactory.getSkill(爆破手.忍耐之盾).getEffect(skillLevel);
                if (player.isAlive() && effect != null) {
                    effect.applyTo(player, true);
                }
            }
        }
    }

    public static void updateShinasBless(MapleCharacter player) {
        int[] arrn = new int[]{80000066, 80000067, 80000068, 80000069, 80000070};
        int n2 = 0;
        Optional<Skill> skill = Optional.ofNullable(SkillFactory.getSkill(80000055));
        for (int n3 : arrn) {
            Skill an3 = SkillFactory.getSkill(n3);
            if (an3 != null && player.getSkillLevel(an3) > 0) {
                n2 += player.getSkillLevel(an3);
            }
        }
        int finalN = n2;
        skill.ifPresent(skill1 -> player.changeSkillData(skill1, finalN == 0 ? -1 : finalN, (byte) skill1.getMasterLevel(), -1));

    }

    public static void doAnimabuff(MapleCharacter player) {
        if (JobConstants.is唤灵斗师(player.getJob())) {
            MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.战法灵气);
            if (effect != null) {
                switch (effect.getSourceid()) {
                    case 32001016:
                    case 唤灵斗师.吸收灵气:
                    case 32111012:
                    case 32121017: {
                        if (player.getParty() != null) {
                            effect.applyTo(player, false);
                        }
                        break;
                    }
                    case 32121018: {
                        effect.applyTo(player, true);
                        break;
                    }
                }
                player.addMP(-effect.getMpCon());
                if (player.getStat().getMp() < effect.getMpCon()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.战法灵气);
                }
            }
        } else if (JobConstants.is神之子(player.getJob())) {
            MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.神圣迅捷);
            if (effect != null && player.getParty() != null) {
                effect.applyTo(player, false);
            }
            if ((effect = player.getStatForBuff(MapleBuffStat.圣洁之力)) != null && player.getParty() != null) {
                effect.applyTo(player, false);
            }
        } else if (JobConstants.is火毒(player.getJob())) {
            Optional.ofNullable(player.getSkillEffect(火毒.元素吸收)).ifPresent(effect -> {
                if (effect.getMonsterStatusSum(player, MonsterStatus.Poison) > 0) {
                    effect.applyTo(player);
                } else {
                    player.cancelEffectFromBuffStat(MapleBuffStat.元素爆破);
                }
            });
            MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.火焰灵气);
            if (statForBuff != null) {
                player.addMP(-statForBuff.getMpCon());
                if (player.getStat().getMp() < statForBuff.getMpCon()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.火焰灵气);
                }
            }
        } else if (JobConstants.is冰雷(player.getJob())) {
            MapleStatEffect statForBuff = player.getStatForBuff(MapleBuffStat.寒冰灵气);
            if (statForBuff != null) {
                player.addMP(-statForBuff.getMpCon());
                if (player.getStat().getMp() < statForBuff.getMpCon()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.寒冰灵气);
                }
            }
        } else if (JobConstants.is米哈尔(player.getJob())) {
            MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.灵魂链接);
            MapleBuffStatValueHolder valueHolder = player.getBuffStatValueHolder(MapleBuffStat.灵魂链接);
            if (effect != null && player.getParty() != null && valueHolder != null && valueHolder.getCid() == player.getId()) {
                player.addMP(-effect.getMpCon());
                effect.applyTo(player, false);
                if (player.getStat().getMp() < effect.getMpCon()) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.灵魂链接);
                }
            }
        } else if (JobConstants.is剑豪(player.getJob())) {
            MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.拔刀术加成);
            MapleBuffStatValueHolder valueHolder = player.getBuffStatValueHolder(MapleBuffStat.拔刀术加成);
            if (effect != null && valueHolder != null && valueHolder.getCid() == player.getId()) {
                player.addMP(-3);
                if (player.getStat().getMp() < 3) {
                    player.cancelEffectFromBuffStat(MapleBuffStat.拔刀术加成);
                }
            }
        } else if (JobConstants.is主教(player.getJob())) {
            MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.祈祷);
            if (effect != null && player.getParty() != null) {
                effect.h(player, false);
            }
        } else if (JobConstants.is恶魔复仇者(player.getJob())) {
            MapleStatEffect effect = player.getStatForBuff(MapleBuffStat.恶魔狂怒);
            if (effect != null && player.getStat().getHp() - effect.getY() > effect.getY() && player.getStat().getHp() - effect.getY() > player.getStat().getCurrentMaxHp() * effect.getQ2() / 100) {
                player.addHPMP(-effect.getY(), 0);
                player.send(MaplePacketCreator.userBonusAttackRequest(恶魔复仇者.恶魔狂怒_2, 0, Collections.emptyList()));
            }
        } else if (JobConstants.is影魂异人(player.getJob())) {
            if (player.getJob() >= 15510 && !player.isSkillCooling(影魂异人.精神力枯竭) && player.getJob() >= 15510 && !player.isSkillCooling(影魂异人.精神力枯竭) && player.getBuffedValue(MapleBuffStat.控制侵蚀) == null) {
                player.addErosions(8);
            }
        }
    }

    public static void switchLuckyMoney(MapleCharacter player, boolean on) {
        if (on && player.getSpecialStat().isLuckymoney()) {
            return;
        }
        player.getSpecialStat().setLuckymoney(on);
        player.getClient().announce(BuffPacket.switchLuckyMoney(on));
    }

    public static void afterTakeDamage(MapleCharacter player, MapleMonster monster, int damage) {
        switch (player.getJob()) {
            case 311:
            case 312: {
                if (damage > 0 || player.getSkillEffect(神射手.闪避) == null) break;
                player.send(MaplePacketCreator.sendCritAttack());
                return;
            }
            case 321:
            case 322: {
                if (damage > 0 || player.getSkillEffect(箭神.闪避) == null) break;
                player.send(MaplePacketCreator.sendCritAttack());
                return;
            }
            case 421:
            case 422: {
                MapleStatEffect skillEffect = player.getSkillEffect(侠盗.进阶隐身术);
                if (damage > 0 && skillEffect != null && Randomizer.isSuccess(skillEffect.getX())) {
                    player.getSkillEffect(飞侠.隐身术).applyTo(player);
                }
                return;
            }
            case 3311:
            case 3312: {
                if (damage > 0 || player.getSkillEffect(豹弩游侠.疾风) == null) break;
                player.send(MaplePacketCreator.sendCritAttack());
                return;
            }
            case 3611:
            case 3612: {
//                if (player.getStatForBuff(MapleBuffStat.影分身) != null) {
//                    player.setShadowHP(player.getShadowHP() - damage);
//                    if (player.getShadowHP() <= 0) {
//                        player.dispelEffect(MapleBuffStat.影分身);
//                    }
//                }
//                final MapleStatEffect effecForBuffStat2 = player.getStatForBuff(MapleBuffStat.宙斯盾系统);
//                if (effecForBuffStat2 != null && effecForBuffStat2.D(player) && player.getCheatTracker().cF()) {
//                    player.getMap().broadcastMessage(player, com.cms.g.a.a.a(mc.a(player, effecForBuffStat2, 0)), true);
//                }
                final MapleStatEffect effecForBuffStat3;
                if ((effecForBuffStat3 = player.getStatForBuff(MapleBuffStat.黑暗高潮)) != null) {
                    effecForBuffStat3.applyTo(player, true);
                }
//                if (c.fr() > 0 && player.getPortableChairID() == 3010587) {
//                    player.getMap().removeAffectedArea(player.getID(), 36121007);
//                    return;
//                }
                break;
            }
        }
    }

//    public static void c(final MapleStatEffect effect, final MapleCharacter player, Point point) {
//        point = ((point != null) ? point : player.getPosition());
//        final MapleMist mist = new MapleMist(MapleStatEffectFactory.calculateBoundingBox(effect, new Point(point.x, point.y + ((effect.getSourceid() == 400010010) ? 40 : 0)), player.isFacingLeft()), player, effect, new Point(point));
//        if (!mist.isMulti()) {
//            player.getMap().removeMist(player.getID(), effect.ed());
//        }
//        player.getMap().createdAffectedArea(f);
//    }
//
//    public static void c(MapleStatEffect effect, MapleCharacter player, Point point) {
//        point = point != null ? point : player.getPosition();
//        int n2 = effect.getSourceid() == 400010010 ? 40 : 0;
//        Cloneable cloneable = new Point(point.x, point.y + n2);
//        point = new com.cms.k.f.f((Rectangle)(cloneable = a.a(effect, cloneable, player.isFacingLeft())), player, effect, new Point((Point)point));
//        if (!point.pW()) {
//            player.getMap().removeAffectedArea(player.getID(), effect.ed());
//        }
//        player.getMap().createdAffectedArea((com.cms.k.f.f)point);
//    }

    public static void spawnMist(final MapleStatEffect effect, final MapleCharacter player, Point point) {
        point = ((point != null) ? point : player.getPosition());
        final MapleMist mist = new MapleMist(MapleStatEffectFactory.calculateBoundingBox(effect, new Point(point.x, point.y + ((effect.getSourceid() == 400010010) ? 40 : 0)), player.isFacingLeft()), player, effect, new Point(point));
        if (!mist.isNotRemove()) {
            player.getMap().removeAffectedArea(player.getId(), effect.getSourceid());
        }
        player.getMap().createdAffectedArea(mist);
    }
}
